Doing Two or More Tasks At Once: Threads |
Therun
method gives a thread something to do. Its code implements the thread's running behavior. It can do anything that can be encoded in Java statements: compute a list of prime's, sort some data, perform some animation.The
Thread
class implements a generic thread that, by default, does nothing. That is, the implementation of itsrun
method is empty. This is not particularly useful, so theThread
class defines API that lets aRunnable
object provide a more interestingrun
method for a thread.There are two techniques for providing a run method for a thread:
Doing Two or More Tasks At Once: Threads |