• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

regaring threads  RSS feed

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the different between object lock and Class lock?

can a synchronize method can be overloaded?
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like homework and we generally don't do others' homework. But these are very simple questions and this morning I am feeling generous...

The class lock is the lock on the java.lang.Class object associated with "this" object. Hence the lock is shared between all objects of the class.

A synchronized method can be overloaded (unless declared "final", of course), but beware because the "synchronized" keyword is not inherited.
 
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Errr is it just me or have you got your overridden and overloaded confused ...

A synchronized method can be overloaded (unless declared "final", of course), but beware because the "synchronized" keyword is not inherited.



Surely 'final' applies to overridden not overloaded i.e. you can declare a final method and overload it just can't override it.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, well spotted. I was answering a question about overriding, when the question asked was in fact about overloading. But then I used the wrong word, too.

I am going to guess that the original poster actually meant overriding, because the question makes no sense for overloading.

If the question really was about overloading, then the answer is that "synchronized" has no effect at all upon what overloading you can do.
[ August 06, 2007: Message edited by: Peter Chase ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!