• Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronizing a block in a static method

 
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: 20820
68
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!