class Test
{
public static void main(String[] args)
{
try
{
for (int i=0;i<10 ;i++)
{
System.out.println("hi");
Thread.sleep(5*1000);
Thread.sleep(5*60*1000);
System.out.println("bye");
}
}
catch (InterruptedException ie)
{
System.out.println("the thread is got innterupted");
}
}
}
import java.util.*;
class MyThread extends Thread
{
public void run()
{
for(int i=0;i<10;i++)
{
Thread.yield();
System.out.println("child thread");
}
}
}
class Test
{
public static void main(String[] args)
{
MyThread t1=new MyThread();
t1.start();
for(int i=0;i<10;i++)
{
System.out.println("main thread");
}
}
}
class MyThread extends Thread
{
public void run()
{
for (int i=0;i<5;i++ )
{
try{
System.out.println("freetimelearn");
Thread.sleep(3*1000);}
catch(InterruptedException iee)
{
System.out.println("gettting innterupted exctpion");
}
}
}
}
class Test
{
public static void main(String[] args)
{
MyThread t1=new MyThread();
MyThread t2=new MyThread();
t1.start();
try
{
t1.join();
}
catch (InterruptedException ie)
{
System.out.println("interrupted Exception");
}
t2.start();
}
};
class MyThread extends Thread
{
public void run()
{
System.out.println(Thread.currentThread().getName());
}
};
class Test
{
public static void main(String[] args)
{
MyThread t=new MyThread();
System.out.println(t.isAlive());
t.start();
System.out.println(t.isAlive());
}
};
class MyThread extends Thread
{
public void run()
{
System.out.println(Thread.currentThread().getName());
}
};
class Test
{
public static void main(String[] args)
{
MyThread t1=new MyThread();
MyThread t2=new MyThread();
MyThread t3=new MyThread();
t1.start();
t2.start();
t3.start();
System.out.println(Thread.activeCount());
}
};
class MyThread extends Thread
{
public void run()
{
System.out.println(Thread.currentThread().getName());
}
};
class Test
{
public static void main(String[] args)
{
MyThread t1=new MyThread();
MyThread t2=new MyThread();
t1.start();
t2.start();
}
};
class MyThread extends Thread
{
public void run()
{
System.out.println(" freetmielearn thread is running ");
}
};
class Test
{
public static void main(String[] args)
{
MyThread t1=new MyThread();
MyThread t2=new MyThread();
t1.start();
t2.start();
System.out.println("the thread id :"+t1.getId());
System.out.println("the thread name is :"+t1.getName());
System.out.println("the thread priority is "+t1.getPriority());
System.out.println("the thread id :"+t2.getId());
System.out.println("the thread name is :"+t2.getName());
System.out.println("the thread priority is "+t2.getPriority());
}
};
class MyThread extends Thread
{
public void run()
{
try
{
for (int i=0;i<10;i++ )
{
System.out.println("i am sleeping ");
Thread.sleep(5000);
}
}
catch (InterruptedException ie)
{
System.out.println("i got interupted by interrupt() call");
}
}
};
class Test
{
public static void main(String[] args)
{
MyThread t=new MyThread();
t.start();
t.interrupt();
}
};