线程工具类ThreadUtils

package yqw.java.util;

 

public class ThreadUtils {

    /**
     * showThreadInfo
     *
     * @return
     */
    public static final String showThreadInfo() {

        return "^^^^^^^^^^^^^^^^^^^^^^^ currentThread: name=" + Thread.currentThread().getName() + "  , id="
                + Thread.currentThread().getId() +

        "   ,state=" + Thread.currentThread().getState() + "   , Priority=" + Thread.currentThread().getPriority();
    }

    /**
     * sleep not catch Exception
     *
     * @param ms
     * @return
     */
    public static boolean sleep(int ms) {
        try {
            Thread.sleep(ms);
            return true;
        } catch (InterruptedException e) {
            return false;
        }
    }
}

posted @ 2018-02-04 12:56  技术新高度  阅读(2325)  评论(0编辑  收藏  举报