Multithreading in java
is a process of executing multiple threads simultaneously.
A thread is a lightweight sub-process, or the set of processing. In simple words we can say that we divide one process into smaller processes.
Let's try to understand: one man takes 50 day to build a house completely. But if we employee 10 men to work concurrently then it can be done within 5 days, exactly same threads done the performances.
Multiprocessing and multithreading, both are used to achieve multitasking.
To implement thread in Programme we can extend Thread class or implement Runnable interface.
Let me explain with one example
class Mythread extends Thread
{
public void run()
{
System.out.println("Child Thread");
}
public static void main(String[] args)
{
Mythread t=new Mythread();
t.start();
}
}
O/p: Child Thread
To learn more about Thread in Java Join TCCI.
Call us @ 9825618292
Visit us @ www.tccicomputercoaching.com
A thread is a lightweight sub-process, or the set of processing. In simple words we can say that we divide one process into smaller processes.
Let's try to understand: one man takes 50 day to build a house completely. But if we employee 10 men to work concurrently then it can be done within 5 days, exactly same threads done the performances.
Multiprocessing and multithreading, both are used to achieve multitasking.
To implement thread in Programme we can extend Thread class or implement Runnable interface.
Let me explain with one example
class Mythread extends Thread
{
public void run()
{
System.out.println("Child Thread");
}
public static void main(String[] args)
{
Mythread t=new Mythread();
t.start();
}
}
O/p: Child Thread
To learn more about Thread in Java Join TCCI.
Call us @ 9825618292
Visit us @ www.tccicomputercoaching.com
No comments:
Post a Comment