package thread1;
//为什么这个程序没有线程的效果?它是先执行完a,再执行b。而不是a,b穿叉执行?
public class test_thread {
public static void main(String[] args) {
Thread a=new Thread(new A());
Thread b=new Thread(new B());
a.start();
b.start();
}}
class A implements Runnable{
public void run()
{
for(int i=0;i<100;i++)
{
System.out.println("A: "+i);
}
}
}
class B implements Runnable {
public void run()
{
for(int i=0;i<100;i++)
{
System.out.println("B: "+i);
}
}
}
//为什么这个程序没有线程的效果?它是先执行完a,再执行b。而不是a,b穿叉执行?
public class test_thread {
public static void main(String[] args) {
Thread a=new Thread(new A());
Thread b=new Thread(new B());
a.start();
b.start();
}}
class A implements Runnable{
public void run()
{
for(int i=0;i<100;i++)
{
System.out.println("A: "+i);
}
}
}
class B implements Runnable {
public void run()
{
for(int i=0;i<100;i++)
{
System.out.println("B: "+i);
}
}
}
class A1 implements Runnable{ @Override
public void run() {
// TODO Auto-generated method stub
for(int i = 0; i < 100; i++){
System.out.println("A:" + i);
try{
Thread.sleep(1000);
}
catch(InterruptedException e){
}
}
}
}