Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Object Monitor Question  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say that I have a single instance of an object, and several references to that object. If I create a synchronized block that synchronizes on one of the object references, is access to the object instance synchronized, or is access to only the reference synchronized?
...Mike Broadbear
 
Mike Broadbear
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for posting under 'broadbear'. Is there any way that account could be deleted?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Done. As for your question - you're really synchronizing on the object, not the reference. Multiple references to the same object are treated equally - the first to attempt to acquire a lock will get it, and the rest will wait.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!