Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

need help on synchronized  RSS feed

 
Mike Liu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can some one explain the difference between the following methods?
public void push(char c){
synchronized(this){
\\code
}
}
public synchronized push(char c){
\\code
}
thanks for helping me out
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it's not obvious, one sync's on the current object in a code block and the other sync's on the current object during the entire execution of the method.
The first is a more fine-grain way to perform sync's on shared resources.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!