how to run a thread program in java multi threading
hai i have complete my multi threading java program .compiling section 2 errors
class ThreadA extends Thread
{
public void run()
{
try
{
for(int i=0; i< 5; i++)
{
Thread.sleep(1000);
System.out.println("Executing first thread");
}
}
catch (InterruptedExpection ex)
{
System.out.println("Thread Interrupted");
}
}
}
class ThreadB extends Thread
{
public void run()
{
try
{
for(int i=0; i< 5; i++)
{
Thread.sleep(2000);
System.out.println("Executing second thread");
}}
catch (InterruptedExpection ex)
{
System.out.println("Thread Interrupted");
}
}
}
class demo3
{
public static void main(String args[])
{
ThreadA t1=new ThreadA();
t1.start();
ThreadB t2=new ThreadB();
t2.start();
}
}
this is my program please give the correct solution
class ThreadA extends Thread
{
public void run()
{
try
{
for(int i=0; i< 5; i++)
{
Thread.sleep(1000);
System.out.println("Executing first thread");
}
}
catch (InterruptedExpection ex)
{
System.out.println("Thread Interrupted");
}
}
}
class ThreadB extends Thread
{
public void run()
{
try
{
for(int i=0; i< 5; i++)
{
Thread.sleep(2000);
System.out.println("Executing second thread");
}}
catch (InterruptedExpection ex)
{
System.out.println("Thread Interrupted");
}
}
}
class demo3
{
public static void main(String args[])
{
ThreadA t1=new ThreadA();
t1.start();
ThreadB t2=new ThreadB();
t2.start();
}
}
this is my program please give the correct solution
0