java线程
class Demo implements Runnable{
private int i = 10;
public void fun()
{
System.out.println(Thread.currentThread().getName() + "在运行```");
}
public void run()
{
while(i-- > 0)
{
this.fun();
}
}
};
public class ThreadDemo1
{
public static void main(String[] args)
{
Demo a = new Demo();
Thread a1 = new Thread(a,"线程1");
Thread a2 = new Thread(a,"线程2");
Thread a3 = new Thread(a,"线程3");
Thread a4 = new Thread(a,"线程4");
a1.start();
a2.start();
a3.start();
a4.start();
}
}
为何会是乱码呢~