Sleep.java 1019 字节
Newer Older
goBD's avatar
goBD 已提交
1 2
package org.wltea.analyzer.help;

3
import org.apache.logging.log4j.Logger;
4

goBD's avatar
goBD 已提交
5
public class Sleep {
6

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    private static final Logger logger = ESPluginLoggerFactory.getLogger(Sleep.class.getName());

    public enum Type {MSEC, SEC, MIN, HOUR}

    ;

    public static void sleep(Type type, int num) {
        try {
            switch (type) {
                case MSEC:
                    Thread.sleep(num);
                    return;
                case SEC:
                    Thread.sleep(num * 1000);
                    return;
                case MIN:
                    Thread.sleep(num * 60 * 1000);
                    return;
                case HOUR:
                    Thread.sleep(num * 60 * 60 * 1000);
                    return;
                default:
                    System.err.println("输入类型错误,应为MSEC,SEC,MIN,HOUR之一");
                    return;
            }
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }
    }
36 37


38
}