import java.util.*; import org.apache.log4j.*; public class ThreadImpl extends Thread { public void run () { BizTask.getInstance().run(); } public static void main(String[] args) { for (int i = 0; i < 100; i++) { ThreadImpl t = new ThreadImpl (); t.start(); } } } class BizTask { private static final Category logger = Category.getInstance (BizTask.class); private static BizTask instance = null; private BizTask() { super(); } public static BizTask getInstance() { if (instance == null) instance = new BizTask(); return instance; } public synchronized void run () { try { Thread.sleep(1000); logger.debug(new Date()); } catch (InterruptedException e) { e.printStackTrace(); } } } <p class="indent">
猜你喜欢
本站原创《复杂软件设计之道:领域驱动设计全面解析与实战》
其他人在看