This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object that is Locked

 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a thread has obtained a lock on an object, i.e. it is within a synchronized block, can another thread modify that object?

For example,
class C{
methodA(){
synchronized(this)
}
methodB(){
}
}

When Thread1 is in synchronized block in methodA, can another thread run methodB

Thanks
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, other non-sync methods could be called simultaneously.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic