Package java.lang
Threads allow the execution of code in a seemingly parallel fashion. There are two ways to create a new thread of execution:
Examples
Method 1:
class MyThread extends Thread { // derive from Thread
public void run() { // implement run() - method
MyThread obj = new MyThread(); // create new object
obj.start(); // start thread, run() will be executed
Method 2:
class class MyThread implements Runnable { // derive from Thread
public void run() { // implement run() - method
MyThread obj = new MyThread(); // create new object
new Thread(obj).start(); // start thread, run() will be executed
The total number of possible threads (including the always present main thread) is currently 9.
Note
Public Constructors
Public Methods
Methods inherited from java.lang.Object
_INSERT_INHERITED_METHOD_ENTRY_HERE_
_INSERT_FIELDS_ENTRY_HERE_