This programme checks the numbers between 0 to 100 and prints the numbers that are not divisible by 10 with a sleeping period of 500 milliseconds.
class ThreadExercise extends Thread
{
public void run(){
for(int i=0;i<=100; i++)
{
if ((i%10) != 0)
{
System.out.println("numbers.... "+i);
try{
Thread.sleep(500);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
public static void main(String[] args)
{
ThreadExercise te=new ThreadExercise();
te.start();
}
}
class ThreadExercise extends Thread
{
public void run(){
for(int i=0;i<=100; i++)
{
if ((i%10) != 0)
{
System.out.println("numbers.... "+i);
try{
Thread.sleep(500);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
public static void main(String[] args)
{
ThreadExercise te=new ThreadExercise();
te.start();
}
}
No comments:
Post a Comment