public class RunnableDemo {
public static void main(String[] args) {
TestRunnable tr=new TestRunnable();
Thread t=new Thread(tr);
t.start();// 通过 Thread 类对象 t 来调用 run ()方法。
while(true)
{
System.out.println("main thread is running");
}
}
}
class TestRunnable implements Runnable
{
public void run()
{
while (true)
{
System.out.println(Thread.currentThread().getName()+" i
s running");
}
}
}