package test; import javax.servlet.*; public class MyCode implements ServletContextListener { //当Tomcat启动时会执行contextInitialized() public void contextInitialized(ServletContextEvent e) { new MyThread().start(); } public void contextDestroyed(ServletCo…
在启动一个线程之后调用该线程的join()方法,会使该线程先执行,该线程执行完成后,再执行调用该线程的线程. 例如如下的任务: public class LiftOff extends Thread { public LiftOff(){ taskCount++;// 计数自增 } private int countDown = 3; // 倒计时数字 private static int taskCount = 0; private int id = taskCount; @Override…