zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java-多线程的实现与启动

JAVA多线程 实现 启动
2023-09-27 14:22:41 时间

class mythread extends Thread  //多线程的启动
{
 private String name;
 public mythread(String name)
 {
  this.name=name;
 }
 public void run()
 {
  for(int i=0;i<10;i++)
  {
   System.out.println("线程"+name+"运行结果:"+i);
  }
 }
}
public class test58 {
 public static void main(String args[])
 {
  mythread a=new mythread("A");
  mythread b=new mythread("B");
  a.start();
  b.start();
 }
}