• 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

Synchronizing from subclass

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

When we have a static synchronized method in a subclass is the lock acquired for super and subclass or subclass only?


My question is, when method run invokes metB from B is lock for A.class and B.class acquired or lock for B.class only? Both methods access static variable a that is defined in A so there can be concurrent access problem when second thread accesses metA in class A. And what about situation in which static method form superclass is redefined in subclass, is there any difference?

When synchronization is involved does it mean that lock for the object (or class) and all the locks for its superclasses' objects (or classes respectively) are acquired?

Thank you in advance
[ October 14, 2007: Message edited by: Wielki Szu ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic