Would you like to react to this message? Create an account in a few clicks or log in to continue.

t.join(); // ͤ觹 Threads Тѹ t 稡͹֧ҧ

 :: ¹ҡѹ :: ѡѺ Threads

Go down

t.join(); // ͤ觹 Threads Тѹ t 稡͹֧ҧ Empty t.join(); // ͤ觹 Threads Тѹ t 稡͹֧ҧ

ตั้งหัวข้อ  Admin Fri May 23, 2008 1:44 am

t.join(); // ͤ觹 Threads Тѹ t 稡͹֧ҧ

package threads;

public class Sample implements Runnable {
String name;



public Sample(String name) {
this.name = name;
}

public synchronized void run() {
for(int i = 0; i < 20; ++i) {
System.out.println(name+" "+i);

try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}

}



}
public static void main(String[] args) {

Thread t = new Thread(new Sample("A"));
Thread t1 = new Thread(new Sample("B"));

t.start();
// t.stop();
System.out.println("Main0");


try {
t.join();
} catch (InterruptedException e) {
e.printStackTrace();
}

System.out.println("Main1");
t1.start();

// t.start();
System.out.println("Main2");
}

}


-------------------------------------
Main0
A 0
A 1
A 2
A 3
A 4
A 5
A 6
A 7
A 8
A 9
A 10
A 11
A 12
A 13
A 14
A 15
A 16
A 17
A 18
A 19
Main1
Main2
B 0
B 1
B 2
B 3
B 4
B 5
B 6
B 7
B 8
B 9
B 10
B 11
B 12
B 13
B 14
B 15
B 16
B 17
B 18
B 19
Admin
Admin
Admin

จำนวนข้อความ : 112
Registration date : 18/05/2008

http://chawban.chocoforum.com

ขึ้นไปข้างบน Go down

ขึ้นไปข้างบน

- Similar topics

 :: ¹ҡѹ :: ѡѺ Threads

 
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ