aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Call Overload Version of Thread's run method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Call Overload Version of Thread Watch "Call Overload Version of Thread New topic
Author

Call Overload Version of Thread's run method

Lennie De Villiers
Greenhorn

Joined: Jul 17, 2009
Posts: 24
Hi,

The Thread class expect a run() method (no arguments), but how can I let it call a overload method? like run(MyClassName aClass)

Regards,

Lennie
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

well you can create your own overloaded method.


but how you will tell to thread.start() to execute my own overloaded run method??
by default thread.start() will execute no-arg run() method!


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
rushikesh sawant
Ranch Hand

Joined: Dec 22, 2009
Posts: 65
you have to call overloaded run method on that particular object. it can be done in run() method which the thread recognizes.


SCJP 5.0 100%
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

yeah you are right rushikesh sawant. now it will become any normal void method
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
Something like this may do what you want:


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Call Overload Version of Thread's run method