aspose file tools*
The moose likes Beginning Java and the fly likes Synchronized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Synchronized" Watch "Synchronized" New topic
Author

Synchronized

Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
What is the purpose of word synchronized in the function:
public syncronized int endRead() {
}
Thanks
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Mike
The simple answer is that synchronized on an instance method means that when the method is executed a lock is aquired on the object associated with the method - the 'this' in the method. And that no other threads can execute synchronized code on that object until the lock is released.
For more info check out the java tutorial section on threads and monitors.


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronized
 
Similar Threads
Vector V/s ArrayList
Why am I getting NullPointerException?
Blocking I/O using Iterator()
THREAD
synchronized context