• Post Reply Bookmark Topic Watch Topic
  • New Topic

syncronization in JAVA  RSS feed

 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
Please let me know where all can we use syncronization in JAVA ?
I think we can make a function/method suncronized in JAVA .Is it possible to suncronize a class ??? if yes how come ??
Do let me know where all can suncronized be used in JAVA ?

Hope to hear from you soon,
Saurabh
 
Nischal Tanna
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
synchronization can be achieved in java by the synchronized keyword
It can be useful while performing secured operations i.e., handling data which shud not be shared among threads... It can be while handling database operation, getting Connection, lazy loading operation (deliberately increasing the execution time which may be useful for gaming software,etc.)

The keyword can be used for a method, block of code.


[ March 15, 2005: Message edited by: Nischal Tanna ]
 
Yaroslav Chinskiy
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saurabh


There are many places where you may use synchronized in Java. However, you need to understand the concept first before. I suggest you read chapter 17 of Java Language Specs (available on sun site) and read Thread forum on this site.

Regarding to class synchronization, I assume you mean synchronizing of the static contest. Since each object in java has to monitors, object's monitor and class monitor, you can lock in the class monitor.

Hope that helps.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Threads and Synchronization...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!