Java Reference
In-Depth Information
ents time durations at given units of granularity:
DAYS
,
HOURS
,
MICROSECONDS
,
MILLISECONDS
,
MINUTES
,
NANOSECONDS
, and
SECONDS
. Furthermore,
TimeUnit
declares methods for converting across units (e.g.,
long
toHours(long duration)
),andforperformingtiminganddelayoperations(e.g.,
void sleep(long timeout)
) in these units.
Table6-1
alsoreferstocallabletasks,whichareanalogoustorunnabletasks.Unlike
Runnable
, whose
void run()
method cannot throw checked exceptions,
Callable<V>
declares a
V call()
method that returns a value, and which can
throwcheckedexceptionsbecause
call()
isdeclaredwitha
throws Exception
clause.
anasynchronouscomputation.
Future
,whosegenerictypeis
Future<V>
,provides
methodsforcancelingatask,forreturningatask'svalue,andfordeterminingwhether