public class Try extends Object
Try: usetry { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); }
Try: Try.sleep(2000); // or Try.sleep(TimeUnit.SECONDS, 2); // or Try.tcf(() -> Thread.sleep(2000));
| 限定符 | 构造器 | 说明 |
|---|---|---|
private |
Try() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static void |
sleep(long milliSeconds) |
Performs a
sleep(long, boolean) |
static void |
sleep(long milliSeconds,
boolean isPrintTrace) |
Performs a
sleep(TimeUnit, long, boolean) |
static void |
sleep(TimeUnit timeUnit,
long timeout) |
Performs a
sleep(TimeUnit, long, boolean) |
static void |
sleep(TimeUnit timeUnit,
long timeout,
boolean isPrintTrace) |
Performs a
TimeUnit.sleep(long) using this time unit |
static <R> R |
tcf(RT0<R,Throwable> tryAction) |
Simplify
try-catch block. |
static <R> R |
tcf(RT0<R,Throwable> tryAction,
boolean isPrintTrace) |
Simplify
try-catch block. |
static <R> R |
tcf(RT0<R,Throwable> tryAction,
V1<Throwable> catchAction) |
Simplify
try-catch block. |
static <R> R |
tcf(RT0<R,Throwable> tryAction,
R defaultReturn,
boolean isPrintTrace) |
Simplify
try-catch block. |
static <R> R |
tcf(RT0<R,Throwable> tryAction,
R defaultReturn,
V1<Throwable> catchAction) |
Simplify
try-catch block. |
static void |
tcf(VT0<Throwable> tryAction) |
Simplify
try-catch block. |
static void |
tcf(VT0<Throwable> tryAction,
boolean isPrintTrace) |
Simplify
try-catch block. |
static void |
tcf(VT0<Throwable> tryAction,
V1<Throwable> catchAction) |
Simplify
try-catch block. |
private static final Logger log
public static void tcf(VT0<Throwable> tryAction)
try-catch block. try-catch 块tryAction - action that maybe throw exceptiontcf(VT0, boolean)public static void tcf(VT0<Throwable> tryAction, boolean isPrintTrace)
try-catch block. try-catch 块tryAction - action that maybe throw exceptionisPrintTrace - isPrintTracepublic static <R> R tcf(RT0<R,Throwable> tryAction)
try-catch block. try-catch 块R - return value typetryAction - action that maybe throw exceptiontcf(RT0, boolean)public static <R> R tcf(RT0<R,Throwable> tryAction, boolean isPrintTrace)
try-catch block. try-catch 块R - return value typetryAction - action that maybe throw exceptionisPrintTrace - isPrintTracetcf(RT0, Object, boolean)public static <R> R tcf(RT0<R,Throwable> tryAction, R defaultReturn, boolean isPrintTrace)
try-catch block. try-catch 块R - return value typetryAction - action that maybe throw exceptiondefaultReturn - default return value when occur exceptionisPrintTrace - isPrintTracepublic static void tcf(VT0<Throwable> tryAction, V1<Throwable> catchAction)
try-catch block. try-catch 块tryAction - action that maybe throw exceptioncatchAction - catchActionpublic static <R> R tcf(RT0<R,Throwable> tryAction, V1<Throwable> catchAction)
try-catch block. try-catch 块R - return value typetryAction - action that maybe throw exceptioncatchAction - catchActiontcf(RT0, Object, V1)public static <R> R tcf(RT0<R,Throwable> tryAction, R defaultReturn, V1<Throwable> catchAction)
try-catch block. try-catch 块R - return value typetryAction - action that maybe throw exceptiondefaultReturn - default return value when occur exceptioncatchAction - catchActionpublic static void sleep(long milliSeconds)
sleep(long, boolean)milliSeconds - the length of time to sleep in millisecondpublic static void sleep(long milliSeconds,
boolean isPrintTrace)
sleep(TimeUnit, long, boolean)milliSeconds - the length of time to sleep in millisecondisPrintTrace - isPrintTracepublic static void sleep(TimeUnit timeUnit, long timeout)
sleep(TimeUnit, long, boolean)timeUnit - timeUnittimeout - the minimum time to sleep. If less than or equal to zero, do not sleep at all.public static void sleep(TimeUnit timeUnit, long timeout, boolean isPrintTrace)
TimeUnit.sleep(long) using this time unittimeUnit - timeUnittimeout - the minimum time to sleep. If less than or equal to zero, do not sleep at all.isPrintTrace - isPrintTraceCopyright © 2023 io-fairy. All rights reserved.