public myThread implements Runnable
{
public void run()
{
System.out.println("I'm running!");
while (1)
{
try
{
Thread.sleep(1000);
}
catch (Exception e) {}
}
}
}public class test
{
myThread t = new myThread();
Thread tt = new Thread(t);
tt.setDaemon(); // 设为 Daemon
tt.start();
}
{
public void run()
{
System.out.println("I'm running!");
while (1)
{
try
{
Thread.sleep(1000);
}
catch (Exception e) {}
}
}
}public class test
{
myThread t = new myThread();
Thread tt = new Thread(t);
tt.setDaemon(); // 设为 Daemon
tt.start();
}
{
public void run()
{
while(true)
{
System.out.println("This is mythread1 running....");
}
}
}
class MyThread2 implements Runnable//能过implements Runnable创建一个线程。实现接口。
{
public void run()
{
while(true)
System.out.println("This is mythread2 running....");
}
};
public class TestThread
{
public static void main(String args[])
{
MyThread1 threadone=new MyThread1();
Thread threadtwo=new Thread(new MyThread2());
threadone.start();
threadtwo.start();
}
};
使用时,另开一个窗体DOS
命令如下:telnet xxx.xxx.xxx.xxx 8189
你的Ip地址敲上几个