logtasktest.java

来自「spring+hibernate+struts 范例代码」· Java 代码 · 共 37 行

JAVA
37
字号
package test.timer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.util.Timer;


/**
 * LogTask客户应用
 *
 * @author luoshifei
 */
public class LogTaskTest {
    protected static final Log log = LogFactory.getLog(LogTaskTest.class);

    public static void main(String[] args) {
        Resource resource = new ClassPathResource("timer-app.xml");
        BeanFactory factory = new XmlBeanFactory(resource);
        Timer timer = (Timer) factory.getBean("timerFactory");

        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            log.error("InterruptedException", e);
        }

        timer.cancel();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?