Skip to content

Instantly share code, notes, and snippets.

@muhomerdogu
Created May 31, 2021 18:05
Show Gist options
  • Save muhomerdogu/addca6a8f4583704f19b6d18b81533dd to your computer and use it in GitHub Desktop.
Save muhomerdogu/addca6a8f4583704f19b6d18b81533dd to your computer and use it in GitHub Desktop.
package thread;
public class KronometreThread implements Runnable {
private Thread thread;
private String threadName;
public KronometreThread(String threadName) {
this.threadName = threadName;
System.out.println("thread oluşturuluyor..");
}
@Override
public void run() {
System.out.println("çalıştırılıyor." + threadName);
try {
for (int i = 0; i <= 10; i++) {
System.out.println(threadName + " :" + i);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Thread bitti.."+threadName);
}
public void start()
{
System.out.println("Thread nesnesi oluşmaktadır.");
if(thread!=null)
{
thread=new Thread(this,threadName);
thread.start();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment