摘要: 我们先看下面一个示例 public class RaceCondition { private static boolean done; public static void main(final String[] args) throws InterruptedException { new Thread(new Runnable() { public void run() { int i = 0; while (!done) { i++; } System.out.println("Done!"); } }).start... 阅读全文
posted @ 2012-11-20 21:04 zhwj184 阅读(248) 评论(0) 推荐(0) 编辑
摘要: public abstract class AbstractPrimeFinder { public boolean isPrime(final int number) { if (number <= 1) return false; for (int i = 2; i <= Math.sqrt(number); i++) if (number % i == 0) return false; return true; } public int countPrimesInRange(final int lower, final int upper) { ... 阅读全文
posted @ 2012-11-20 14:29 zhwj184 阅读(373) 评论(0) 推荐(0) 编辑