• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread.stop()

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Some authors claim that the stop method has been deprecated because it can cause objects to be permanently locked by a stopped thread. However, that claim is not valid.

A stopped thread exits all synchronized methods it has called—technically, by throwing a ThreadDeath exception. As a consequence, the thread relinquishes the intrinsic object locks that it holds."

SourceCore Java Volume 1 (8th Edition) P.762

Does anyone have supporting technical documents on the issue?
 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jon Camilleri wrote:"Some authors claim that the stop method has been deprecated because it can cause objects to be permanently locked by a stopped thread. However, that claim is not valid.

A stopped thread exits all synchronized methods it has called—technically, by throwing a ThreadDeath exception. As a consequence, the thread relinquishes the intrinsic object locks that it holds."

SourceCore Java Volume 1 (8th Edition) P.762


The statement is both correct and incorrect -- it depends on what the definition of lock is. If the definition of lock is purely the object locks, the locks grabbed by the synchronized keyword, then yes, the statement is correct. All synchronized locks are released, as the ThreadDeath throwable object unwinds the stack.

If the definition is more general, to include internal variables/flags/state that are used to "lock the JVM", then it is arguably incorrect. It is possible for the ThreadDeath to unwind the thread that leaves some of these flags in an incorrect state, preventing the JVM from functioning correctly.

Henry
 
Javin Paul
Ranch Hand
Posts: 295
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry for your reply , its make a lot of sense.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jon, please don't ever post 1800 lines of code. In fact, don't ever post even 180 lines of code. Nobody has the inclination to read through that much.
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Jon, please don't ever post 1800 lines of code. In fact, don't ever post even 180 lines of code. Nobody has the inclination to read through that much.

sorry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!