|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.realtime.HighResolutionTime
Used to express time with nanosecond accuracy. This class is never
used directly: it is abstract and has no public constructors.
Instead, use one of its subclasses AbsoluteTime, RelativeTime, or
RationalTime. When an API is defined that has an HighResolutionTime
as a parameter, it can take either an absolute, relative, or
rational time and will do something appropriate. All of the
arithmetic functions come in both allocating and non-allocating
forms. The standard Java java.util.Date class uses milliseconds as
its basic unit in order to provide sufficient range for a wide
variety of applications. Real-time programming generally requires
nanosecond resolution, but even a 64 bit real-time clock based in
nanoseconds would be problematic in some situations, so a compound
format composed of 64 bits of millisecond timing, and 32 bits of
nanoseconds within a millisecond, was chosen.
Caution: This class is explicitly unsafe in multithreaded
situations when it is being changed. No synchronization is done. It
is assumed that users of this class who are mutating instances will
be doing their own synchronization at a higher level.
Field Summary | |
protected long |
millis
|
protected int |
nanos
|
Constructor Summary | |
protected |
HighResolutionTime(long millis,
int nanos)
|
Method Summary | |
int |
compareTo(HighResolutionTime time)
Compares this to another time object. |
int |
compareTo(Object time)
Compares this to another time object. |
boolean |
equals(HighResolutionTime time)
Determines whether this time equals a given other time. |
boolean |
equals(Object time)
Determines whether this time equals a given other time. |
long |
getMilliseconds()
Gets the milliseconds component associated with this time. |
int |
getNanoseconds()
Gets the nanoseconds component associated with this time. |
int |
hashCode()
|
void |
set(HighResolutionTime time)
Changes the time represented by the argument to some time between the invocation of the method and the return of the method. |
void |
set(long millis)
Sets the millisecond component of this to the given argument. |
void |
set(long millis,
int nanos)
Sets the millisecond and nanosecond components of this. |
static void |
waitForObject(Object target,
HighResolutionTime time)
Deprecated. Don't use this method! |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected long millis
protected int nanos
Constructor Detail |
protected HighResolutionTime(long millis, int nanos)
Method Detail |
public int compareTo(Object time)
compareTo
in interface Comparable
time
- the time against which "this" time has to be
compared.
public int compareTo(HighResolutionTime time)
time
- the time against which "this" time has to be
compared.
public boolean equals(HighResolutionTime time)
time
- the time value compared to this.
public boolean equals(Object time)
time
- the time value compared to this.
public final long getMilliseconds()
public final int getNanoseconds()
public int hashCode()
public void set(HighResolutionTime time)
time
- The HighResolutionTime which will be set to
represent the current time.public void set(long millis)
millis
- This value will be the value of the millisecond
component of this at the completion of the call. If millis is
negative the millisecond value of this is set to negative
value. Although logically this may represent time before the
epoch, invalid resultsmayoccur if a HighResolutionTime
representing time before the epoch is given as a parameter to
the methods.public void set(long millis, int nanos)
millis
- Value to set millisecond part of this. If millis
is negative the millisecond value of this is set to negative
value. Although logically this may represent time before the
epoch, invalid resultsmayoccur if a HighResolutionTime
representing time before the epoch is given as a parameter to
the methods.nanos
- Value to set nanosecond part of this. If nanos is
negative the millisecond value of this is set to negative
value. Although logically this may represent time before the
epoch, invalid resultsmayoccur if a HighResolutionTime
representing time before the epoch is given as a parameter to
the methods.public static void waitForObject(Object target, HighResolutionTime time) throws InterruptedException
target
- The object on which to wait. The current thread
must have a lock on the object.time
- The time for which to wait. If this is
RelativeTime(0,0) then wait indefinitely.
InterruptedException
- If another threads interrupts
this thread while its waiting.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |