fixed some formatting typos
[vimdoclet.git] / sample / java.util.concurrent.TimeUnit.txt
blob83df8057289ed41e545f98a7ac514942b8c32a52
1 *java.util.concurrent.TimeUnit* *TimeUnit* A TimeUnit represents time durations 
3 public enumTimeUnit
4   extends    |java.lang.Enum|
6 |java.util.concurrent.TimeUnit_Description|
7 |java.util.concurrent.TimeUnit_Fields|
8 |java.util.concurrent.TimeUnit_Constructors|
9 |java.util.concurrent.TimeUnit_Methods|
11 ================================================================================
13 *java.util.concurrent.TimeUnit_Methods*
14 |java.util.concurrent.TimeUnit.convert(long,TimeUnit)|Convert the given time du
15 |java.util.concurrent.TimeUnit.sleep(long)|Performs a Thread.sleep using this u
16 |java.util.concurrent.TimeUnit.timedJoin(Thread,long)|Performs a timed Thread.j
17 |java.util.concurrent.TimeUnit.timedWait(Object,long)|Performs a timed Object.w
18 |java.util.concurrent.TimeUnit.toDays(long)|Equivalent to DAYS.convert(duration
19 |java.util.concurrent.TimeUnit.toHours(long)|Equivalent to HOURS.convert(durati
20 |java.util.concurrent.TimeUnit.toMicros(long)|Equivalent to MICROSECONDS.conver
21 |java.util.concurrent.TimeUnit.toMillis(long)|Equivalent to MILLISECONDS.conver
22 |java.util.concurrent.TimeUnit.toMinutes(long)|Equivalent to MINUTES.convert(du
23 |java.util.concurrent.TimeUnit.toNanos(long)|Equivalent to NANOSECONDS.convert(
24 |java.util.concurrent.TimeUnit.toSeconds(long)|Equivalent to SECONDS.convert(du
25 |java.util.concurrent.TimeUnit.valueOf(String)|
26 |java.util.concurrent.TimeUnit.values()|
28 *java.util.concurrent.TimeUnit_Description*
30 A TimeUnit represents time durations at a given unit of granularity and 
31 provides utility methods to convert across units, and to perform timing and 
32 delay operations in these units. A TimeUnit does not maintain time information, 
33 but only helps organize and use time representations that may be maintained 
34 separately across various contexts. A nanosecond is defined as one thousandth 
35 of a microsecond, a microsecond as one thousandth of a millisecond, a 
36 millisecond as one thousandth of a second, a minute as sixty seconds, an hour 
37 as sixty minutes, and a day as twenty four hours. 
39 A TimeUnit is mainly used to inform time-based methods how a given timing 
40 parameter should be interpreted. For example, the following code will timeout 
41 in 50 milliseconds if the lock(|java.util.concurrent.locks.Lock|) is not 
42 available: 
44 Lock lock = ...; if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ... 
46 while this code will timeout in 50 seconds: 
48 Lock lock = ...; if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ... 
50 Note however, that there is no guarantee that a particular timeout 
51 implementation will be able to notice the passage of time at the same 
52 granularity as the given TimeUnit. 
56 *java.util.concurrent.TimeUnit.convert(long,TimeUnit)*
58 public long convert(
59   long sourceDuration,
60   java.util.concurrent.TimeUnit sourceUnit)
62 Convert the given time duration in the given unit to this unit. Conversions 
63 from finer to coarser granularities truncate, so lose precision. For example 
64 converting 999 milliseconds to seconds results in 0. Conversions from coarser 
65 to finer granularities with arguments that would numerically overflow saturate 
66 to Long.MIN_VALUE if negative or Long.MAX_VALUE if positive. 
68 For example, to convert 10 minutes to milliseconds, use: 
69 TimeUnit.MILLISECONDS.convert(10L, TimeUnit.MINUTES) 
72     sourceDuration - the time duration in the given sourceUnit 
73     sourceUnit - the unit of the sourceDuration argument 
75     Returns: the converted duration in this unit, or Long.MIN_VALUE if conversion would 
76              negatively overflow, or Long.MAX_VALUE if it would positively 
77              overflow. 
79 *java.util.concurrent.TimeUnit.sleep(long)*
81 public void sleep(long timeout)
82   throws |java.lang.InterruptedException|
83          
84 Performs a Thread.sleep using this unit. This is a convenience method that 
85 converts time arguments into the form required by the Thread.sleep method. 
88     timeout - the minimum time to sleep. If less than or equal to zero, do not sleep at all. 
90 *java.util.concurrent.TimeUnit.timedJoin(Thread,long)*
92 public void timedJoin(
93   java.lang.Thread thread,
94   long timeout)
95   throws |java.lang.InterruptedException|
96          
97 Performs a timed Thread.join using this time unit. This is a convenience method 
98 that converts time arguments into the form required by the Thread.join method. 
101     thread - the thread to wait for 
102     timeout - the maximum time to wait. If less than or equal to zero, do not wait at all. 
104 *java.util.concurrent.TimeUnit.timedWait(Object,long)*
106 public void timedWait(
107   java.lang.Object obj,
108   long timeout)
109   throws |java.lang.InterruptedException|
110          
111 Performs a timed Object.wait using this time unit. This is a convenience method 
112 that converts timeout arguments into the form required by the Object.wait 
113 method. 
115 For example, you could implement a blocking poll method (see 
116 BlockingQueue.poll(|java.util.concurrent.BlockingQueue|) ) using: 
118 public synchronized Object poll(long timeout, TimeUnit unit) throws 
119 InterruptedException { while (empty) { unit.timedWait(this, timeout); ... } } 
122     obj - the object to wait on 
123     timeout - the maximum time to wait. If less than or equal to zero, do not wait at all. 
125 *java.util.concurrent.TimeUnit.toDays(long)*
127 public long toDays(long duration)
129 Equivalent to DAYS.convert(duration, this). 
132     duration - the duration 
134     Returns: the converted duration 
136 *java.util.concurrent.TimeUnit.toHours(long)*
138 public long toHours(long duration)
140 Equivalent to HOURS.convert(duration, this). 
143     duration - the duration 
145     Returns: the converted duration, or Long.MIN_VALUE if conversion would negatively 
146              overflow, or Long.MAX_VALUE if it would positively overflow. 
148 *java.util.concurrent.TimeUnit.toMicros(long)*
150 public long toMicros(long duration)
152 Equivalent to MICROSECONDS.convert(duration, this). 
155     duration - the duration 
157     Returns: the converted duration, or Long.MIN_VALUE if conversion would negatively 
158              overflow, or Long.MAX_VALUE if it would positively overflow. 
160 *java.util.concurrent.TimeUnit.toMillis(long)*
162 public long toMillis(long duration)
164 Equivalent to MILLISECONDS.convert(duration, this). 
167     duration - the duration 
169     Returns: the converted duration, or Long.MIN_VALUE if conversion would negatively 
170              overflow, or Long.MAX_VALUE if it would positively overflow. 
172 *java.util.concurrent.TimeUnit.toMinutes(long)*
174 public long toMinutes(long duration)
176 Equivalent to MINUTES.convert(duration, this). 
179     duration - the duration 
181     Returns: the converted duration, or Long.MIN_VALUE if conversion would negatively 
182              overflow, or Long.MAX_VALUE if it would positively overflow. 
184 *java.util.concurrent.TimeUnit.toNanos(long)*
186 public long toNanos(long duration)
188 Equivalent to NANOSECONDS.convert(duration, this). 
191     duration - the duration 
193     Returns: the converted duration, or Long.MIN_VALUE if conversion would negatively 
194              overflow, or Long.MAX_VALUE if it would positively overflow. 
196 *java.util.concurrent.TimeUnit.toSeconds(long)*
198 public long toSeconds(long duration)
200 Equivalent to SECONDS.convert(duration, this). 
203     duration - the duration 
205     Returns: the converted duration, or Long.MIN_VALUE if conversion would negatively 
206              overflow, or Long.MAX_VALUE if it would positively overflow. 
208 *java.util.concurrent.TimeUnit.valueOf(String)*
210 public static |java.util.concurrent.TimeUnit| valueOf(java.lang.String name)
216 *java.util.concurrent.TimeUnit.values()*
218 public static final |java.util.concurrent.TimeUnit|[] values()