|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread org.apache.commons.id.uuid.clock.ThreadClockImpl
public final class ThreadClockImpl
Clock
provides a timing mechanism for returning the current time in
100-nano second intervals since 00:00:00.00, 15 October 1582.
This Class consumes a single thread which will die off if not utilized before the expiration. Subsequent calls after a thread expires start a new thread. Compensates for jvm time resolution issues. This clock should be used in instances where the system resolution does not perform adequately - the clocking resolution on some windows virtual machines can range from 10 to 50 milliseconds before the System.currentTimeMillis changes. In instances where 10,000 or more uuid's may be generated in a millisecond this Clock implementation may be required.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static long |
DEFAULT_THREAD_LIFE
Default time to live of the Clock thread in milliseconds |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface org.apache.commons.id.uuid.clock.Clock |
---|
DEFAULT_CLOCK_IMPL, GREGORIAN_CHANGE_OFFSET, INTERVALS_PER_MILLI |
Constructor Summary | |
---|---|
ThreadClockImpl()
Public constructor to instantiate a Clock instance. |
Method Summary | |
---|---|
static long |
getThreadLife()
Returns the thread life in milliseconds. |
long |
getUUIDTime()
Method returns the clocks current time in 100-nanosecond intervals since the Gregorian calander change. |
void |
run()
Threads run method that increments the clock and resets the generated nano seconds counter. |
static void |
setThreadLife(long threadLifeLen)
|
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULT_THREAD_LIFE
Constructor Detail |
---|
public ThreadClockImpl()
Public constructor to instantiate a Clock instance.
Method Detail |
---|
public static long getThreadLife()
public static void setThreadLife(long threadLifeLen)
threadLifeLen
- milliseconds this thread should live for. Each
call to getCurrentTime resets the expiration time value.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public long getUUIDTime() throws OverClockedException
getUUIDTime
in interface Clock
OverClockedException
- an exception when the number of timestamps
generated exceeds the allowable timestamps for the system time
interval.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |