Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ThreaDish

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic