Thread
Thread
Thread
Extending java.lang.Thread
EX:-
class MyThread extends Thread {
public void run() {
System.out.println("Important job running in
MyThread");
}
}
Implementing java.lang.Runnable
Ex:-
class MyRunnable implements Runnable {
public void run() {
System.out.println("Important job running in
MyRunnable");
}
}
Thread States
Thread.MIN_PRIORITY (1)
Thread.NORM_PRIORITY (5)
Thread.MAX_PRIORITY (10)
OR
threadobj.setPriority(int value);
threadobj.getPriority();
Thread Synchronization
Statement ;
}
Ex:-
synchronized void display() {
Ststement;
}
sleep() Method
try {
Thread.sleep(5*60*1000); // Sleep for 5 minutes
}catch (InterruptedException ex) { }
The methods static :-- sleep() and yield(), and which are
not static:--join() and start()are methods of
java.lang.Thread.