This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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 ]
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!