Search This Blog

save java programs with".java" extension

examples :

helloworld.java
sample.java
match.java
send-mail.java

quick links

runnable example

class mythreadone implements Runnable
{
public void run()
{
for(int i=1;i<=10;i++)
System.out.println(i);
try
{
Thread.sleep(400);
}
catch(Exception e)
{
}
}
}

class mythreadtwo implements Runnable
{
public void run()
{
for(int j=11;j<=20;j++)
System.out.println(j);
try
{
Thread.sleep(400);
}
catch(Exception e)
{
}
}

}
class runnableexample {

public static void main(String[] args) {
Thread rt1=new Thread(new mythreadone());
Thread rt2=new Thread(new mythreadtwo());
rt1.start();
rt2.start();

}

}