File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Synchronization" Watch "Synchronization" New topic
Author

Synchronization

Saurabh Saha
Ranch Hand

Joined: Dec 08, 2004
Posts: 52
Hi All,
Can any object call one Synchronized and one non-Syncronized method at a time.
method1() //Synchronized
method2() //non Synchronized

can any object like object1 call both method1 and method2 method at the same time.

Thanks,
Vivek
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Objects don't call methods. Threads call methods on objects.

Any number of threads can simultaneously execute unsynchronised methods on the same object.

Only one thread at a time can execute any synchronised method on the same object. Other threads have to wait.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Mishra Vivek:
... Can any object call one Synchronized and one non-Syncronized method at a time.
method1() //Synchronized
method2() //non Synchronized
...

My understanding (please confirm/correct me) is that these aren't really called at the same time. The first method must return before the second is called.

But in any case, before a synchronized method can be executed, its object (or class) lock must be obtained by the calling thread.
[ February 15, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronization