Why is Thread.run() declared public? Shouldn't it be declared protected, as only the Thread superclass can invoke it?

Alex Chaffee

One reason is that Thread implements Runnable, which requires that run() be public. This is an unfortunate consequence of the definition of Java interfaces.

It is also not clear whether you would want to prohibit other classes from calling a Thread's run() method in a synchronous manner -- as it is, they have the option of calling either run() or start() depending on their needs.

But you're right, it feels wrong. :-)

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact