• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Synchronization

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic