别听千里的...讲得好像生成随机数好似++操作一样简单~~按照他那么做你的性能开销就划不来了
[CODE]...
import java.util.Random;
/**
*
* @author vlinux
*/
public class RandomThread extends Thread {
private int randomNumber;
public int getRandomNumber() {
return randomNumber;
}
public void run() {
Random random = new Random();
randomNumber = random.nextInt();
System.out.println("Random Thread is done!");
}
public static void main( String... args ) throws InterruptedException {
RandomThread randomThread = new RandomThread();
randomThread.start();
randomThread.join();
int randomNumber = randomThread.getRandomNumber();
System.out.println( randomNumber );
System.out.println( "Main Thread is done!" );
}
}
[/CODE]
[CODE]...
import java.util.Random;
/**
*
* @author vlinux
*/
public class RandomThread extends Thread {
private int randomNumber;
public int getRandomNumber() {
return randomNumber;
}
public void run() {
Random random = new Random();
randomNumber = random.nextInt();
System.out.println("Random Thread is done!");
}
public static void main( String... args ) throws InterruptedException {
RandomThread randomThread = new RandomThread();
randomThread.start();
randomThread.join();
int randomNumber = randomThread.getRandomNumber();
System.out.println( randomNumber );
System.out.println( "Main Thread is done!" );
}
}
[/CODE]
淘宝杜琨