package duoxiancheng;
class The extends Thread//继承Thread创建多线程
{
String s;
The(String s)//此构造函数是为了自定义线程名称
{
this.s=s;
}
public void run()//覆盖run方法
{
for(int i=0;i<=10;i++)
{
System.out.println(s+"...run");
}
}
}
public class TheadDemo1 {
public static void main(String [] args)
{
The t1=new The("one");
The t2=new The("two");
t1.start();
t2.start();
}
}
(多线程)TheadDemo1
最新推荐文章于 2022-10-17 20:57:03 发布