37 |
|
be used in conjunction with a {@link |
38 |
|
java.util.concurrent.CancellableTask} or {@link |
39 |
|
java.util.concurrent.FutureTask} to asynchronously start a potentially |
40 |
< |
long-running computation and query the FutureTask to determine if its |
41 |
< |
execution has completed, or cancel it. |
40 |
> |
long-running computation and query to determine if its execution has |
41 |
> |
completed, or cancel it. |
42 |
|
|
43 |
|
<p> The {@link java.util.concurrent.Executors} class provides factory |
44 |
|
methods for the most common kinds and configurations of Executors, as |
46 |
|
|
47 |
|
<h2>Queues</h2> |
48 |
|
|
49 |
< |
The java.util.concurrent {@link |
49 |
> |
The java.util.concurrent {@link |
50 |
|
java.util.concurrent.ConcurrentLinkedQueue} class supplies an |
51 |
< |
efficient scalable thread-safe non-blocking FIFO queue. |
52 |
< |
|
53 |
< |
<p> Five implementations in java.util.concurrent support the extended |
54 |
< |
{@link java.util.concurrent.BlockingQueue} interface, that defines |
55 |
< |
blocking versions of put and take: {@link |
51 |
> |
efficient scalable thread-safe non-blocking FIFO queue. Five |
52 |
> |
implementations in java.util.concurrent support the extended {@link |
53 |
> |
java.util.concurrent.BlockingQueue} interface, that defines blocking |
54 |
> |
versions of put and take: {@link |
55 |
|
java.util.concurrent.LinkedBlockingQueue}, {@link |
56 |
|
java.util.concurrent.ArrayBlockingQueue}, {@link |
57 |
|
java.util.concurrent.SynchronousQueue}, {@link |
67 |
|
granularities (including nanoseconds) for specifying and controlling |
68 |
|
time-out based operations. Nearly all other classes in the package |
69 |
|
contain operations based on time-outs in addition to indefinite waits. |
70 |
< |
|
72 |
< |
<p>In all cases that time-outs are used, the time-out specifies the |
70 |
> |
In all cases that time-outs are used, the time-out specifies the |
71 |
|
minimum time that the method should wait before indicating that it |
72 |
|
timed-out. The virtual machine should make a "best effort" |
73 |
|
to detect time-outs as soon as possible after they occur. Regardless |
96 |
|
java.util.concurrent.CopyOnWriteArrayList}, and {@link |
97 |
|
java.util.concurrent.CopyOnWriteArraySet}. |
98 |
|
|
99 |
< |
<p>The "Concurrent" prefix for classes is a shorthand |
100 |
< |
indicating several differences from similar "synchronized" |
99 |
> |
<p>The "Concurrent" prefix used with some classes in this package is a |
100 |
> |
shorthand indicating several differences from similar "synchronized" |
101 |
|
classes. For example <tt>java.util.Hashtable</tt> and |
102 |
|
<tt>Collections.synchronizedMap(new HashMap())</tt> are |
103 |
< |
synchronized. But {@link |
104 |
< |
java.util.concurrent.ConcurrentHashMap} is "concurrent". |
105 |
< |
A concurrent collection (among other kinds of classes) is |
106 |
< |
thread-safe, but not governed by a single exclusion lock. So, in the |
107 |
< |
particular case of ConcurrentHashMap, it safely permits any number of |
108 |
< |
concurrent reads as well as a tunable number of concurrent writes. |
109 |
< |
There may still be a role for "synchronized" classes in some |
110 |
< |
multithreaded programs -- they can sometimes be useful when you need |
111 |
< |
to prevent ALL access to a collection via a single lock, at the |
112 |
< |
expense of much poor scalability. In all other cases, "concurrent" |
115 |
< |
versions are normally preferable. |
103 |
> |
synchronized. But {@link java.util.concurrent.ConcurrentHashMap} is |
104 |
> |
"concurrent". A concurrent collection is thread-safe, but not |
105 |
> |
governed by a single exclusion lock. In the particular case of |
106 |
> |
ConcurrentHashMap, it safely permits any number of concurrent reads as |
107 |
> |
well as a tunable number of concurrent writes. There may still be a |
108 |
> |
role for "synchronized" classes in some multithreaded programs -- they |
109 |
> |
can sometimes be useful when you need to prevent all access to a |
110 |
> |
collection via a single lock, at the expense of much poor |
111 |
> |
scalability. In all other cases, "concurrent" versions are normally |
112 |
> |
preferable. |
113 |
|
|
114 |
|
<p> Most concurrent Collection implementations (including most Queues) |
115 |
|
also differ from the usual java.util conventions in that their Iterators |