This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes synchronize variable by lock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "synchronize variable by lock" Watch "synchronize variable by lock" New topic
Author

synchronize variable by lock

Stefan Müllerheim
Greenhorn

Joined: Sep 17, 2010
Posts: 12
hi, i try to synchronize the access to a variable and wrote something below. is that correct? see anybody any fault?


less is more.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18914
    
  40

BTW, there is no need to create a new local variable...



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: synchronize variable by lock