ballfly
发贴: 7
积分: 0
|
于 2006-03-08 00:33
import java.io.*; public class fourThread implements Runnable { public static void main(String args[]) { fourThread th=new fourThread(); Thread th1=new Thread(th); Thread th2=new Thread(th); Thread th3=new Thread(th); Thread th4=new Thread(th); th1.start(); th2.start(); th3.start(); th4.start(); } int i=100;
public void run() { for(;i>=50;i--) { System.out.println(Thread.currentThread().getName()+":"+i); } } }
为何屏幕会打印出4个重复的93数字呢? 我的目的是:从100到50的不重复打印(用四个线程实现) 请问如何解决?
|