Threads
Threads are used to get the multiple activities in a single process.
They are light weight programs.
They share memory and files and process state.
They have their own local variable and stack and program counter.
Every java program creates at least one thread main()
Other are added using the thread constructor or instantiating the classes extending the thread class.
java.lang* package is use to run the threads.
ex
public class MyThread extends Thread {
public void run(){
System.out.println("thread is running...");
}
public static void main(String[] args) {
MyThread obj = new MyThread();
obj.start();
}
0 Comment(s)