aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ThreaDish Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ThreaDish" Watch "ThreaDish" New topic
Author

ThreaDish

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Helo!
This is not a deadlock but leads to a dead-end alright:

now here is another way to handle StamPeed:

Is this right way todo this?
In real world features of StamPeed are not that simple (actually features are not known) but the idea of blockage is there.

------------------
Antti Barck
It Solutions Consultant -- NSD Oy
Sun Certified Programmer for the Java� 2 Platform
Metal Zhang
Ranch Hand

Joined: Aug 05, 2001
Posts: 52
I think the statement in your first program will never be invoked.Because this is a single thread program,the statement will not be invoked before the return of the statement .You know,the statment will never return,we call it "dead loop".
------------------
Java lover from hell!
[This message has been edited by Metal Zhang (edited August 21, 2001).]


Java lover from hell!
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Helo Metal Zhang!
I think you missed the point, but I realized that instead of using anonymous thread in start method, I can implement the class from Runnable and do the stuff in run. Stopping thread is still a bugger (especially with vicious classes like StamPeed)
------------------
Antti Barck
It Solutions Consultant -- NSD Oy
Sun Certified Programmer for the Java™ 2 Platform
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
Metal Zhang, obj.stop() will be invoked in the main Thread, which is a different Thread from the one started by obj.start(). These two Threads have the same priority and will both share the cpu. Hence obj.stop() WILL be called before obj.start() returns.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ThreaDish