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
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: Toy code for Java Thread

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT杂谈