Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Catherine austin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Catherine austin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell and Sathiesh..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic