This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronizing a block in a static method  RSS feed

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following code in our ConnectionSingleton class. I want to remove synchronized from method and put it inside the method using double check idiom. For block synchronization I am unable to use "this" because the method is static. How can I resolve this issue. There is too much code in our applications that calls this method so I would like to keep it static.

Thanks
Imad

 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Synchronize on the class object:
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
awesome. Thanks.
 
Andrei Matyas
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be interesting for you to read the following : http://www.ibm.com/developerworks/java/library/j-dcl.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!