File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes need help on synchronized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "need help on synchronized" Watch "need help on synchronized" New topic

need help on synchronized

Mike Liu

Joined: Jan 24, 2002
Posts: 3
Hi, can some one explain the difference between the following methods?
public void push(char c){
public synchronized push(char c){
thanks for helping me out
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
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.

<a href="" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
I agree. Here's the link:
subject: need help on synchronized
jQuery in Action, 3rd edition