Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threads

 
FENG
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what's differently lock action on an object and lock on Threads?
Thanks!
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s3528090,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name to comply with our unique rule. Thank you.
All Java objects have what we call a lock. By synchronizing some code on an object, you can obtain exclusive access to that object. Since a Thread is an object, you can also get a lock on a Thread instance. Sometimes, when a thread is executing, it needs to get the lock of some object to continue its execution. If it cannot obtain the object lock, the thread will be "suspended" until it manages to get the lock to that object.
Please, read the following for completeness:
JLS 17.13 Locks and Synchronization
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic