簡易計時器TimeCounter,拿去就用,別整那些花裏胡哨的

public class TimeCounter {

    private static final ThreadLocal<Long> time = new ThreadLocal<>();

    public static void start() {
        time.set(System.currentTimeMillis());
    }

    public static long end() {
        Long start = time.get();
        if (start == null) {
            return 0;
        }
        return System.currentTimeMillis() - start;
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章