• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we put synchronized keyword infront of run method of Runnable interface ?

 
vitthal wable
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we make run metohd synchronized if so then what about overriding the run from Runnable interface?pls reply Soon
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you try? And what are you trying to achieve?
[ November 14, 2006: Message edited by: �dne Brunborg ]
 
Harshil Mehta
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if so then what about overriding the run from Runnable interface?


if you put synchronized keyword in any superclass/interface method, it is still a legal overriding.
 
vitthal wable
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to know that if i am making it synchronized then i am changing the signature of run() method from class which is implementing it means i am breaking the overriding rule...
 
Rambabu Gonela
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a subclass method matches in name and in the number and type of arguments to the method in the super-class (that is, the method signatures match), the subclass is said to override that method.

Here synchronized is not part of method signature, so you are not breaking overriding rule ..
ok
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic