jabber, let me try ...

canada (canada)
Let me try to express my opnion on this program.

the output is OK when the second Thread.sleep(15000) waits longer time than the first one. If we change 15000 to a number less than 1000, there will have a problem while running. When the while(){} is not over and the System.out.println("I came here") begins, the mt is not null. And System.out.println("I am not null") will be excuted. After this, mt.start() will bring problem because mt has already started. The problem will be catched by system because of try{...}catch{...}. Then the e.printStackTrace() will be executed. The rest output of System.out.println("x = "+ x); is OK.

2000-11-12 -04:00

回到话题: Toy code for Java Thread

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT杂谈