@@ -0,0 +1,1417 @@
+package com.jfw.thread;%0A%0Aimport com.jfw.thread.safe.SynCounter;%0Aimport com.jfw.thread.unsafe.UnsafeThread;%0A%0Apublic class TestThread %7B%0A%0A%09static int value = 1000;%0A%09static int loops = 0;%0A%09public static void main(String%5B%5D args) throws InterruptedException  %7B%0A//%09%09testUnsafeThread();%0A%09%09testSafeThread();%0A%09%7D%0A%09%0A%09public static void  testUnsafeThread() throws InterruptedException%7B%0A%09%09ThreadGroup tg = Thread.currentThread().getThreadGroup();%0A%09%09while (loops++ %3C 50) %7B%0A%09%09%09UnsafeThread run = new UnsafeThread();%0A%09%09%09for (int i = 0; i %3C value; i++) %7B%0A%09%09%09%09new Thread(run, %22%E7%BA%BF%E7%A8%8B%22 + loops + %22-%22 + i).start();%0A%09%09%09%7D%0A%09%09%09do %7B%0A%09%09%09%09Thread.sleep(15);%0A%09%09%09%7D while (tg.activeCount() != 1);%0A%0A%09%09%09if (run.getCount() != value) %7B%0A%09%09%09%09System.out.println(%22%E5%BE%AA%E7%8E%AF%E5%88%B0%22 + loops + %22%E6%AC%A1%EF%BC%8C%E5%87%BA%E7%8E%B0%E7%BA%BF%E7%A8%8B%E4%B8%8D%E5%AE%89%E5%85%A8%22);%0A%09%09%09%09System.out.println(%22%E6%9C%80%E7%BB%88%E5%80%BC%E4%B8%BA%22 + run.getCount());%0A%09%09%09%09System.exit(0);%0A%09%09%09%7D%0A%0A%09%09%7D%0A%09%09System.out.println(%22%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8%22);%0A%09%7D%0A%09%0A%09public static void  testSafeThread() throws InterruptedException%7B%0A%09%09ThreadGroup tg = Thread.currentThread().getThreadGroup();%0A%09%09while (loops++ %3C 50) %7B%0A%09%09%09SynCounter run = new SynCounter();%0A%09%09%09for (int i = 0; i %3C value; i++) %7B%0A%09%09%09%09new Thread(run, %22%E7%BA%BF%E7%A8%8B%22 + loops + %22-%22 + i).start();%0A%09%09%09%7D%0A%09%09%09do %7B%0A%09%09%09%09Thread.sleep(15);%0A%09%09%09%7D while (tg.activeCount() != 1);%0A%0A%09%09%09if (run.getCount() != value) %7B%0A%09%09%09%09System.out.println(%22%E5%BE%AA%E7%8E%AF%E5%88%B0%22 + loops + %22%E6%AC%A1%EF%BC%8C%E5%87%BA%E7%8E%B0%E7%BA%BF%E7%A8%8B%E4%B8%8D%E5%AE%89%E5%85%A8%22);%0A%09%09%09%09System.out.println(%22%E6%9C%80%E7%BB%88%E5%80%BC%E4%B8%BA%22 + run.getCount());%0A%09%09%09%09System.exit(0);%0A%09%09%09%7D%0A%0A%09%09%7D%0A%09%09System.out.println(%22%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8%22);%0A%09%7D%0A%0A%7D%0A

Create TestThread.java