| Share this post! | Vote this! |
|
A java thread is an execution context or a lightweight process. It is a single sequential flow of control within a program. Programmer may use java thread mechanism to execute multiple tasks at the same time.
Thread class and run() Method
Basic support for threads is in the java.lang.Thread class. It provides a thread API and all the generic behavior for threads. These behaviors include starting, sleeping, running, yielding, and having a priority.
The run() method gives a thread something to do. Its code should implement the thread's running behavior.
There are two ways of creating a customized thread:
Sub classing java.lang.Thread and Overriding run() method.
Implementing the java.lang.Runnable Interface.




0 comments:
Post a Comment