package test;
public class ThreadJoinExample implements Runnable {
int l;
public ThreadJoinExample() {
super();
}
public ThreadJoinExample(int forInt) {
super();
l=forInt;
}
public void run() {
for (int i = 1; i <= l; i++) {
System.out.println("This is message # Thread Name "
+Thread.currentThread().getName()+" -------"+ i);
}
}
public static void main(String[] args) {
Thread t1 = new Thread(new ThreadJoinExample(10));
Thread t2 = new Thread(new ThreadJoinExample(100));
Thread t3 = new Thread(new ThreadJoinExample(10));
t1.start();
t2.start();
t3.start();
try {
t1.join();
System.out.println("1. thread bitti Join Arası ne olcak acaba");
System.out.println("I'm " + Thread.currentThread().getName());
t2.join();
System.out.println("2. thread bitti Join Arası ne olcak acaba");
System.out.println("I'm " + Thread.currentThread().getName());
t3.join();
} catch (InterruptedException ex) {
// do nothing
}
System.out.println("I'm " + Thread.currentThread().getName());
}
}
Yorumlar
Yorum Gönder