@ThreadSafe public class ThreadLocalTimer extends Object implements StopWatch
ThreadLocal
based stop watch is safe to use with multiple threads as it will time each thread's call
between reset()
(or construction) and lap()
. It is intended to use one shared Clock
.
For example, RealClock
but you could use a clock based on ThreadLocal
if you need to provide different
clocks per thread (although, outside of a testing context, I'm not sure why you'd want to).Constructor and Description |
---|
ThreadLocalTimer(Clock clock) |
Modifier and Type | Method and Description |
---|---|
Duration |
elapsedTime() |
void |
lap()
mark a lap, this method can be invoked multiple times but should be called before making a call to the
StopWatch.elapsedTime() method. |
void |
reset()
start or reset the stop watch starting position.
|
public ThreadLocalTimer(Clock clock)
public void reset()
StopWatch
StopWatch.lap()
.public void lap()
StopWatch
StopWatch.elapsedTime()
method.public Duration elapsedTime()
elapsedTime
in interface StopWatch
Copyright © 2009–2017 tempus-fugit committers. All rights reserved.