aspose file tools*
The moose likes Beginning Java and the fly likes Can we define run() in another method of the class ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can we define run() in another method of the class ??" Watch "Can we define run() in another method of the class ??" New topic
Author

Can we define run() in another method of the class ??

Catherine austin
Ranch Hand

Joined: Jul 20, 2011
Posts: 43
To create Thread we need to override run() in case we implements Runnable interface. But can we define this run() method in another method of that class?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
Don't understand your question. Sorry.

You cannot have methods inside methods.
You can simply call another method from inside run, like thisI don't think that answers your query, however.
Sathiesh Kumar Vs
Ranch Hand

Joined: Oct 24, 2010
Posts: 31
Seems your need is to run() a thread inside some other method.

If that is the case, you will have to create a Separate Thread and implements run() method in that. And use that thread here as Campbell said.
Or you can use an anonymous inner class.

Sorry, If I misunderstood your question.


Thanks and Regards,
Sathiesh.
Catherine austin
Ranch Hand

Joined: Jul 20, 2011
Posts: 43
Thanks Campbell and Sathiesh..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we define run() in another method of the class ??