aspose file tools
The moose likes I/O and Streams and the fly likes runnable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "runnable" Watch "runnable" New topic
Author

runnable

yasir badshah
Greenhorn

Joined: Mar 14, 2002
Posts: 5
what is runnable class & what it's work tell me.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Yasir,
Runnable isn't a class, its an interface with just one method:

The class Thread implements Runnable, but its run method doesn't do anything so you have to overload it if you extend Thread and want to do some work in a separate thread. Most of the time programmers choose to implement the Runnable interface since that allows them to extend a different more appropriate class for the type of work they are doing. This works fine because the Thread class has a constructor which takes a Runnable as a parameter. After the Thread object is constructed then all you have to do is call its start() method and your Runnable is off and running (sorry for the pun) like this:

Hope this helps
Michael Morris
SCJP


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
I meant that you have to override the run() method, not overload it.
Sorry about that
Michael Morris
SCJP
 
 
subject: runnable
 
Threads others viewed
run method
Semi-Urgent
thread
thread question
Thread Question
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture