wood burning stoves
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

Win a copy of Building Microservices this week in the Design forum!
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="http://www.rajindery.com" 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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: need help on synchronized
It's not a secret anymore!