当前位置: 技术问答>java相关
接口是什么意思
来源: 互联网 发布时间:2015-05-08
本文导语: class twothread implements Runnable { twothread() { Thread t1=Thread.currentThread(); t1.setName("The first main thread"); System.out.println("The running thread:"+t1); //********************************* ...
class twothread implements Runnable
{
twothread()
{
Thread t1=Thread.currentThread();
t1.setName("The first main thread");
System.out.println("The running thread:"+t1); //*********************************
Thread t2=new Thread(this,"these cond thread");
System.out.println("creat another thread");
t2.start();
try
{
System.out.println("first thread will sleep");
Thread.sleep(3000);
}
catch(InterruptedException e)
{
System.out.println("first thread has wrong");
}
System.out.println("first thread exit");
}
public void run()
{
try
{
for(int i=0;i
{
twothread()
{
Thread t1=Thread.currentThread();
t1.setName("The first main thread");
System.out.println("The running thread:"+t1); //*********************************
Thread t2=new Thread(this,"these cond thread");
System.out.println("creat another thread");
t2.start();
try
{
System.out.println("first thread will sleep");
Thread.sleep(3000);
}
catch(InterruptedException e)
{
System.out.println("first thread has wrong");
}
System.out.println("first thread exit");
}
public void run()
{
try
{
for(int i=0;i