Thread is the most important part for concurrent execution.
Thread is the light wait process that means one process can be divided in to small small threads which will execute concurrently for fast execution of tasks.
All Java programs have at least one thread, known as the main thread, which is created by the JVM at the program’s start, when the main() method is invoked with the main thread. In Java, creating a thread is accomplished by implementing an interface and extending a class. Every Java thread is created and controlled by the java.lang.Thread class.
A Thread class extends Object class and implements Runnable interface. The one advantage of using Runnable interface over Thread class, is that the class which implements Runnable interface can extend one class or implement multiple interfaces which is not possible by extending thread class.
Example
1. class Multi extends Thread{
2. public void run(){
3. System.out.println("thread is running...");
4. }
5. public static void main(String args[]){
6. Multi t1=new Multi();
7. t1.start();
8. }
9. }
TCCI Computer Coaching Institute teach Thread in Java in Bopal and Satellite in Ahmedabad.
You can Join Programming Language Course at TCCI. Online Coaching is also available.
For more information about Computer Courses at TCCI .
Visit us @ http://tccicomputercoaching.com/computer-it-engineering-course/
Call us @ 98256 18292
Thread is the light wait process that means one process can be divided in to small small threads which will execute concurrently for fast execution of tasks.
All Java programs have at least one thread, known as the main thread, which is created by the JVM at the program’s start, when the main() method is invoked with the main thread. In Java, creating a thread is accomplished by implementing an interface and extending a class. Every Java thread is created and controlled by the java.lang.Thread class.
A Thread class extends Object class and implements Runnable interface. The one advantage of using Runnable interface over Thread class, is that the class which implements Runnable interface can extend one class or implement multiple interfaces which is not possible by extending thread class.
Example
1. class Multi extends Thread{
2. public void run(){
3. System.out.println("thread is running...");
4. }
5. public static void main(String args[]){
6. Multi t1=new Multi();
7. t1.start();
8. }
9. }
TCCI Computer Coaching Institute teach Thread in Java in Bopal and Satellite in Ahmedabad.
You can Join Programming Language Course at TCCI. Online Coaching is also available.
For more information about Computer Courses at TCCI .
Visit us @ http://tccicomputercoaching.com/computer-it-engineering-course/
Call us @ 98256 18292
No comments:
Post a Comment