In Java, Multithreading refers to a process of executing two or more threads sim
In Java, Multithreading refers to a process of executing two or more threads simultaneously for maximum utilization of the CPU. A thread in Java is a lightweight process requiring fewer resources to create and share the process resources.
class MultiThreads
{
public static void main(String[] args)
{
System.out.println(Thread.currentThread().getName());
for (int i = 0; i < 10; i++)
{
new Thread("" + i)
{
public void run()
{
System.out.println("Thread: " + getName() + " running");
}
}.start();
}
}
OUTPUT
Thread: 1 running
Thread: 0 running
Thread: 2 running
Thread: 4 running
Thread: 3 running
Thread: 5 running
Thread: 6 running
Thread: 7 running
Thread: 8 running
Thread: 9 running
