• Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronization and static  RSS feed

 
Neha Mohit
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In case of syncronization of static methods which object gets synchronized.


Thanks in advance
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For static, there is only one so synchronize implies that is the only one.

Without the static keyword:


Now when program logic gets to the word synchronized, only one thing at a time happens. Synchronizing of Threads is not usually necessary at the beginner level.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static methods synchronize on the class object of a class (the object returned by the getClass() method). This means that only one synchronized static method of a class can run at any one time.
 
Neha Mohit
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joanne , i got it now.

regards
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!