Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3459dfdc
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3459dfdc
编写于
12月 01, 2010
作者:
D
dl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7003745: Code style cleanups (sync from Dougs CVS)
Reviewed-by: chegar, dholmes
上级
fe7ceb20
变更
78
显示空白变更内容
内联
并排
Showing
78 changed file
with
586 addition
and
535 deletion
+586
-535
src/share/classes/java/util/AbstractCollection.java
src/share/classes/java/util/AbstractCollection.java
+33
-36
src/share/classes/java/util/AbstractList.java
src/share/classes/java/util/AbstractList.java
+15
-15
src/share/classes/java/util/AbstractMap.java
src/share/classes/java/util/AbstractMap.java
+1
-1
src/share/classes/java/util/ArrayList.java
src/share/classes/java/util/ArrayList.java
+4
-4
src/share/classes/java/util/Collections.java
src/share/classes/java/util/Collections.java
+76
-76
src/share/classes/java/util/ComparableTimSort.java
src/share/classes/java/util/ComparableTimSort.java
+4
-4
src/share/classes/java/util/Random.java
src/share/classes/java/util/Random.java
+4
-4
src/share/classes/java/util/Stack.java
src/share/classes/java/util/Stack.java
+6
-6
src/share/classes/java/util/TimSort.java
src/share/classes/java/util/TimSort.java
+4
-4
src/share/classes/java/util/TreeMap.java
src/share/classes/java/util/TreeMap.java
+13
-12
src/share/classes/java/util/TreeSet.java
src/share/classes/java/util/TreeSet.java
+2
-2
src/share/classes/java/util/Vector.java
src/share/classes/java/util/Vector.java
+1
-1
src/share/classes/java/util/concurrent/AbstractExecutorService.java
...classes/java/util/concurrent/AbstractExecutorService.java
+10
-12
src/share/classes/java/util/concurrent/ConcurrentHashMap.java
...share/classes/java/util/concurrent/ConcurrentHashMap.java
+2
-2
src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
...e/classes/java/util/concurrent/ConcurrentLinkedDeque.java
+22
-23
src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
...e/classes/java/util/concurrent/ConcurrentLinkedQueue.java
+7
-7
src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
...e/classes/java/util/concurrent/ConcurrentSkipListSet.java
+2
-2
src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
...re/classes/java/util/concurrent/CopyOnWriteArrayList.java
+2
-2
src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java
...are/classes/java/util/concurrent/CopyOnWriteArraySet.java
+12
-13
src/share/classes/java/util/concurrent/CountDownLatch.java
src/share/classes/java/util/concurrent/CountDownLatch.java
+1
-1
src/share/classes/java/util/concurrent/DelayQueue.java
src/share/classes/java/util/concurrent/DelayQueue.java
+8
-6
src/share/classes/java/util/concurrent/Exchanger.java
src/share/classes/java/util/concurrent/Exchanger.java
+7
-5
src/share/classes/java/util/concurrent/Executor.java
src/share/classes/java/util/concurrent/Executor.java
+26
-26
src/share/classes/java/util/concurrent/ExecutorCompletionService.java
...asses/java/util/concurrent/ExecutorCompletionService.java
+2
-1
src/share/classes/java/util/concurrent/Executors.java
src/share/classes/java/util/concurrent/Executors.java
+7
-7
src/share/classes/java/util/concurrent/Future.java
src/share/classes/java/util/concurrent/Future.java
+9
-11
src/share/classes/java/util/concurrent/FutureTask.java
src/share/classes/java/util/concurrent/FutureTask.java
+1
-1
src/share/classes/java/util/concurrent/LinkedBlockingDeque.java
...are/classes/java/util/concurrent/LinkedBlockingDeque.java
+12
-10
src/share/classes/java/util/concurrent/RecursiveAction.java
src/share/classes/java/util/concurrent/RecursiveAction.java
+3
-1
src/share/classes/java/util/concurrent/ScheduledExecutorService.java
...lasses/java/util/concurrent/ScheduledExecutorService.java
+14
-15
src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java
...ses/java/util/concurrent/ScheduledThreadPoolExecutor.java
+6
-6
src/share/classes/java/util/concurrent/Semaphore.java
src/share/classes/java/util/concurrent/Semaphore.java
+3
-3
src/share/classes/java/util/concurrent/ThreadLocalRandom.java
...share/classes/java/util/concurrent/ThreadLocalRandom.java
+3
-3
src/share/classes/java/util/concurrent/TimeUnit.java
src/share/classes/java/util/concurrent/TimeUnit.java
+23
-19
src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
...ava/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+2
-2
src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
...s/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+8
-8
src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
...a/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+6
-7
src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
...util/concurrent/locks/AbstractQueuedLongSynchronizer.java
+16
-9
src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
...ava/util/concurrent/locks/AbstractQueuedSynchronizer.java
+17
-10
src/share/classes/java/util/concurrent/locks/LockSupport.java
...share/classes/java/util/concurrent/locks/LockSupport.java
+2
-2
src/share/classes/java/util/concurrent/locks/ReentrantLock.java
...are/classes/java/util/concurrent/locks/ReentrantLock.java
+6
-5
src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
...es/java/util/concurrent/locks/ReentrantReadWriteLock.java
+13
-10
test/java/util/concurrent/BlockingQueue/Interrupt.java
test/java/util/concurrent/BlockingQueue/Interrupt.java
+1
-1
test/java/util/concurrent/BlockingQueue/LoopHelpers.java
test/java/util/concurrent/BlockingQueue/LoopHelpers.java
+3
-3
test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java
test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java
+3
-3
test/java/util/concurrent/ConcurrentHashMap/MapCheck.java
test/java/util/concurrent/ConcurrentHashMap/MapCheck.java
+38
-38
test/java/util/concurrent/ConcurrentHashMap/MapLoops.java
test/java/util/concurrent/ConcurrentHashMap/MapLoops.java
+2
-2
test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java
test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java
+3
-3
test/java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java
...java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java
+1
-1
test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java
.../java/util/concurrent/CopyOnWriteArraySet/RacingCows.java
+1
-1
test/java/util/concurrent/CyclicBarrier/Basic.java
test/java/util/concurrent/CyclicBarrier/Basic.java
+3
-3
test/java/util/concurrent/Exchanger/ExchangeLoops.java
test/java/util/concurrent/Exchanger/ExchangeLoops.java
+4
-4
test/java/util/concurrent/Exchanger/LoopHelpers.java
test/java/util/concurrent/Exchanger/LoopHelpers.java
+3
-3
test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java
...utorCompletionService/ExecutorCompletionServiceLoops.java
+1
-1
test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java
...til/concurrent/ExecutorCompletionService/LoopHelpers.java
+3
-3
test/java/util/concurrent/Executors/Throws.java
test/java/util/concurrent/Executors/Throws.java
+1
-1
test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java
...java/util/concurrent/FutureTask/BlockingTaskExecutor.java
+1
-1
test/java/util/concurrent/FutureTask/CancelledFutureLoops.java
...java/util/concurrent/FutureTask/CancelledFutureLoops.java
+3
-3
test/java/util/concurrent/FutureTask/Customized.java
test/java/util/concurrent/FutureTask/Customized.java
+1
-1
test/java/util/concurrent/FutureTask/LoopHelpers.java
test/java/util/concurrent/FutureTask/LoopHelpers.java
+3
-3
test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java
...concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java
+2
-5
test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
...ava/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
+3
-3
test/java/util/concurrent/ThreadPoolExecutor/Custom.java
test/java/util/concurrent/ThreadPoolExecutor/Custom.java
+3
-3
test/java/util/concurrent/ThreadPoolExecutor/ScheduledTickleService.java
...concurrent/ThreadPoolExecutor/ScheduledTickleService.java
+2
-2
test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java
...concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java
+3
-3
test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
...ava/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
+18
-18
test/java/util/concurrent/atomic/VMSupportsCS8.java
test/java/util/concurrent/atomic/VMSupportsCS8.java
+2
-0
test/java/util/concurrent/locks/Lock/FlakyMutex.java
test/java/util/concurrent/locks/Lock/FlakyMutex.java
+2
-2
test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java
test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java
+1
-1
test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java
...il/concurrent/locks/ReentrantLock/CancelledLockLoops.java
+2
-2
test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java
...oncurrent/locks/ReentrantLock/LockOncePerThreadLoops.java
+1
-1
test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java
...java/util/concurrent/locks/ReentrantLock/LoopHelpers.java
+3
-3
test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java
...current/locks/ReentrantLock/SimpleReentrantLockLoops.java
+1
-1
test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java
...util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java
+2
-0
test/java/util/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java
...l/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java
+1
-1
test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java
.../concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java
+3
-3
test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java
...til/concurrent/locks/ReentrantReadWriteLock/MapLoops.java
+2
-2
test/java/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java
...a/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java
+45
-16
未找到文件。
src/share/classes/java/util/AbstractCollection.java
浏览文件 @
3459dfdc
...
...
@@ -96,14 +96,14 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws NullPointerException {@inheritDoc}
*/
public
boolean
contains
(
Object
o
)
{
Iterator
<
E
>
e
=
iterator
();
Iterator
<
E
>
it
=
iterator
();
if
(
o
==
null
)
{
while
(
e
.
hasNext
())
if
(
e
.
next
()==
null
)
while
(
it
.
hasNext
())
if
(
it
.
next
()==
null
)
return
true
;
}
else
{
while
(
e
.
hasNext
())
if
(
o
.
equals
(
e
.
next
()))
while
(
it
.
hasNext
())
if
(
o
.
equals
(
it
.
next
()))
return
true
;
}
return
false
;
...
...
@@ -269,18 +269,18 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws NullPointerException {@inheritDoc}
*/
public
boolean
remove
(
Object
o
)
{
Iterator
<
E
>
e
=
iterator
();
Iterator
<
E
>
it
=
iterator
();
if
(
o
==
null
)
{
while
(
e
.
hasNext
())
{
if
(
e
.
next
()==
null
)
{
e
.
remove
();
while
(
it
.
hasNext
())
{
if
(
it
.
next
()==
null
)
{
it
.
remove
();
return
true
;
}
}
}
else
{
while
(
e
.
hasNext
())
{
if
(
o
.
equals
(
e
.
next
()))
{
e
.
remove
();
while
(
it
.
hasNext
())
{
if
(
o
.
equals
(
it
.
next
()))
{
it
.
remove
();
return
true
;
}
}
...
...
@@ -304,9 +304,8 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @see #contains(Object)
*/
public
boolean
containsAll
(
Collection
<?>
c
)
{
Iterator
<?>
e
=
c
.
iterator
();
while
(
e
.
hasNext
())
if
(!
contains
(
e
.
next
()))
for
(
Object
e
:
c
)
if
(!
contains
(
e
))
return
false
;
return
true
;
}
...
...
@@ -331,11 +330,9 @@ public abstract class AbstractCollection<E> implements Collection<E> {
*/
public
boolean
addAll
(
Collection
<?
extends
E
>
c
)
{
boolean
modified
=
false
;
Iterator
<?
extends
E
>
e
=
c
.
iterator
();
while
(
e
.
hasNext
())
{
if
(
add
(
e
.
next
()))
for
(
E
e
:
c
)
if
(
add
(
e
))
modified
=
true
;
}
return
modified
;
}
...
...
@@ -362,10 +359,10 @@ public abstract class AbstractCollection<E> implements Collection<E> {
*/
public
boolean
removeAll
(
Collection
<?>
c
)
{
boolean
modified
=
false
;
Iterator
<?>
e
=
iterator
();
while
(
e
.
hasNext
())
{
if
(
c
.
contains
(
e
.
next
()))
{
e
.
remove
();
Iterator
<?>
it
=
iterator
();
while
(
it
.
hasNext
())
{
if
(
c
.
contains
(
it
.
next
()))
{
it
.
remove
();
modified
=
true
;
}
}
...
...
@@ -395,10 +392,10 @@ public abstract class AbstractCollection<E> implements Collection<E> {
*/
public
boolean
retainAll
(
Collection
<?>
c
)
{
boolean
modified
=
false
;
Iterator
<
E
>
e
=
iterator
();
while
(
e
.
hasNext
())
{
if
(!
c
.
contains
(
e
.
next
()))
{
e
.
remove
();
Iterator
<
E
>
it
=
iterator
();
while
(
it
.
hasNext
())
{
if
(!
c
.
contains
(
it
.
next
()))
{
it
.
remove
();
modified
=
true
;
}
}
...
...
@@ -421,10 +418,10 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @throws UnsupportedOperationException {@inheritDoc}
*/
public
void
clear
()
{
Iterator
<
E
>
e
=
iterator
();
while
(
e
.
hasNext
())
{
e
.
next
();
e
.
remove
();
Iterator
<
E
>
it
=
iterator
();
while
(
it
.
hasNext
())
{
it
.
next
();
it
.
remove
();
}
}
...
...
@@ -442,18 +439,18 @@ public abstract class AbstractCollection<E> implements Collection<E> {
* @return a string representation of this collection
*/
public
String
toString
()
{
Iterator
<
E
>
i
=
iterator
();
if
(!
i
.
hasNext
())
Iterator
<
E
>
i
t
=
iterator
();
if
(!
i
t
.
hasNext
())
return
"[]"
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
'['
);
for
(;;)
{
E
e
=
i
.
next
();
E
e
=
i
t
.
next
();
sb
.
append
(
e
==
this
?
"(this Collection)"
:
e
);
if
(!
i
.
hasNext
())
if
(!
i
t
.
hasNext
())
return
sb
.
append
(
']'
).
toString
();
sb
.
append
(
", "
);
sb
.
append
(
','
).
append
(
' '
);
}
}
...
...
src/share/classes/java/util/AbstractList.java
浏览文件 @
3459dfdc
...
...
@@ -175,15 +175,15 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
* @throws NullPointerException {@inheritDoc}
*/
public
int
indexOf
(
Object
o
)
{
ListIterator
<
E
>
e
=
listIterator
();
ListIterator
<
E
>
it
=
listIterator
();
if
(
o
==
null
)
{
while
(
e
.
hasNext
())
if
(
e
.
next
()==
null
)
return
e
.
previousIndex
();
while
(
it
.
hasNext
())
if
(
it
.
next
()==
null
)
return
it
.
previousIndex
();
}
else
{
while
(
e
.
hasNext
())
if
(
o
.
equals
(
e
.
next
()))
return
e
.
previousIndex
();
while
(
it
.
hasNext
())
if
(
o
.
equals
(
it
.
next
()))
return
it
.
previousIndex
();
}
return
-
1
;
}
...
...
@@ -200,15 +200,15 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
* @throws NullPointerException {@inheritDoc}
*/
public
int
lastIndexOf
(
Object
o
)
{
ListIterator
<
E
>
e
=
listIterator
(
size
());
ListIterator
<
E
>
it
=
listIterator
(
size
());
if
(
o
==
null
)
{
while
(
e
.
hasPrevious
())
if
(
e
.
previous
()==
null
)
return
e
.
nextIndex
();
while
(
it
.
hasPrevious
())
if
(
it
.
previous
()==
null
)
return
it
.
nextIndex
();
}
else
{
while
(
e
.
hasPrevious
())
if
(
o
.
equals
(
e
.
previous
()))
return
e
.
nextIndex
();
while
(
it
.
hasPrevious
())
if
(
o
.
equals
(
it
.
previous
()))
return
it
.
nextIndex
();
}
return
-
1
;
}
...
...
@@ -517,7 +517,7 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
ListIterator
<
E
>
e1
=
listIterator
();
ListIterator
e2
=
((
List
)
o
).
listIterator
();
while
(
e1
.
hasNext
()
&&
e2
.
hasNext
())
{
while
(
e1
.
hasNext
()
&&
e2
.
hasNext
())
{
E
o1
=
e1
.
next
();
Object
o2
=
e2
.
next
();
if
(!(
o1
==
null
?
o2
==
null
:
o1
.
equals
(
o2
)))
...
...
src/share/classes/java/util/AbstractMap.java
浏览文件 @
3459dfdc
...
...
@@ -523,7 +523,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
sb
.
append
(
value
==
this
?
"(this Map)"
:
value
);
if
(!
i
.
hasNext
())
return
sb
.
append
(
'}'
).
toString
();
sb
.
append
(
", "
);
sb
.
append
(
','
).
append
(
' '
);
}
}
...
...
src/share/classes/java/util/ArrayList.java
浏览文件 @
3459dfdc
...
...
@@ -121,7 +121,7 @@ public class ArrayList<E> extends AbstractList<E>
* Constructs an empty list with the specified initial capacity.
*
* @param initialCapacity the initial capacity of the list
* @
exception
IllegalArgumentException if the specified initial capacity
* @
throws
IllegalArgumentException if the specified initial capacity
* is negative
*/
public
ArrayList
(
int
initialCapacity
)
{
...
...
src/share/classes/java/util/Collections.java
浏览文件 @
3459dfdc
...
...
@@ -124,7 +124,7 @@ public class Collections {
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
* ascending and descending order in different parts of the
the
same
* ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
...
...
@@ -184,7 +184,7 @@ public class Collections {
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
* ascending and descending order in different parts of the
the
same
* ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
...
...
@@ -823,7 +823,7 @@ public class Collections {
i
-=
size
;
displaced
=
list
.
set
(
i
,
displaced
);
nMoved
++;
}
while
(
i
!=
cycleStart
);
}
while
(
i
!=
cycleStart
);
}
}
...
...
@@ -1452,9 +1452,9 @@ public class Collections {
* when o is a Map.Entry, and calls o.setValue.
*/
public
boolean
containsAll
(
Collection
<?>
coll
)
{
Iterator
<?>
e
=
coll
.
iterator
();
while
(
e
.
hasNext
())
if
(!
contains
(
e
.
next
()))
// Invokes safe contains() above
Iterator
<?>
it
=
coll
.
iterator
();
while
(
it
.
hasNext
())
if
(!
contains
(
it
.
next
()))
// Invokes safe contains() above
return
false
;
return
true
;
}
...
...
@@ -1562,7 +1562,7 @@ public class Collections {
* <pre>
* Collection c = Collections.synchronizedCollection(myCollection);
* ...
* synchronized(c) {
* synchronized
(c) {
* Iterator i = c.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -1611,19 +1611,19 @@ public class Collections {
}
public
int
size
()
{
synchronized
(
mutex
)
{
return
c
.
size
();}
synchronized
(
mutex
)
{
return
c
.
size
();}
}
public
boolean
isEmpty
()
{
synchronized
(
mutex
)
{
return
c
.
isEmpty
();}
synchronized
(
mutex
)
{
return
c
.
isEmpty
();}
}
public
boolean
contains
(
Object
o
)
{
synchronized
(
mutex
)
{
return
c
.
contains
(
o
);}
synchronized
(
mutex
)
{
return
c
.
contains
(
o
);}
}
public
Object
[]
toArray
()
{
synchronized
(
mutex
)
{
return
c
.
toArray
();}
synchronized
(
mutex
)
{
return
c
.
toArray
();}
}
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
synchronized
(
mutex
)
{
return
c
.
toArray
(
a
);}
synchronized
(
mutex
)
{
return
c
.
toArray
(
a
);}
}
public
Iterator
<
E
>
iterator
()
{
...
...
@@ -1631,32 +1631,32 @@ public class Collections {
}
public
boolean
add
(
E
e
)
{
synchronized
(
mutex
)
{
return
c
.
add
(
e
);}
synchronized
(
mutex
)
{
return
c
.
add
(
e
);}
}
public
boolean
remove
(
Object
o
)
{
synchronized
(
mutex
)
{
return
c
.
remove
(
o
);}
synchronized
(
mutex
)
{
return
c
.
remove
(
o
);}
}
public
boolean
containsAll
(
Collection
<?>
coll
)
{
synchronized
(
mutex
)
{
return
c
.
containsAll
(
coll
);}
synchronized
(
mutex
)
{
return
c
.
containsAll
(
coll
);}
}
public
boolean
addAll
(
Collection
<?
extends
E
>
coll
)
{
synchronized
(
mutex
)
{
return
c
.
addAll
(
coll
);}
synchronized
(
mutex
)
{
return
c
.
addAll
(
coll
);}
}
public
boolean
removeAll
(
Collection
<?>
coll
)
{
synchronized
(
mutex
)
{
return
c
.
removeAll
(
coll
);}
synchronized
(
mutex
)
{
return
c
.
removeAll
(
coll
);}
}
public
boolean
retainAll
(
Collection
<?>
coll
)
{
synchronized
(
mutex
)
{
return
c
.
retainAll
(
coll
);}
synchronized
(
mutex
)
{
return
c
.
retainAll
(
coll
);}
}
public
void
clear
()
{
synchronized
(
mutex
)
{
c
.
clear
();}
synchronized
(
mutex
)
{
c
.
clear
();}
}
public
String
toString
()
{
synchronized
(
mutex
)
{
return
c
.
toString
();}
synchronized
(
mutex
)
{
return
c
.
toString
();}
}
private
void
writeObject
(
ObjectOutputStream
s
)
throws
IOException
{
synchronized
(
mutex
)
{
s
.
defaultWriteObject
();}
synchronized
(
mutex
)
{
s
.
defaultWriteObject
();}
}
}
...
...
@@ -1671,7 +1671,7 @@ public class Collections {
* <pre>
* Set s = Collections.synchronizedSet(new HashSet());
* ...
* synchronized(s) {
* synchronized
(s) {
* Iterator i = s.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -1709,10 +1709,10 @@ public class Collections {
}
public
boolean
equals
(
Object
o
)
{
synchronized
(
mutex
)
{
return
c
.
equals
(
o
);}
synchronized
(
mutex
)
{
return
c
.
equals
(
o
);}
}
public
int
hashCode
()
{
synchronized
(
mutex
)
{
return
c
.
hashCode
();}
synchronized
(
mutex
)
{
return
c
.
hashCode
();}
}
}
...
...
@@ -1728,7 +1728,7 @@ public class Collections {
* <pre>
* SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
* ...
* synchronized(s) {
* synchronized
(s) {
* Iterator i = s.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -1739,7 +1739,7 @@ public class Collections {
* SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
* SortedSet s2 = s.headSet(foo);
* ...
* synchronized(s) { // Note: s, not s2!!!
* synchronized
(s) { // Note: s, not s2!!!
* Iterator i = s2.iterator(); // Must be in the synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -1766,7 +1766,7 @@ public class Collections {
{
private
static
final
long
serialVersionUID
=
8695801310862127406L
;
final
private
SortedSet
<
E
>
ss
;
private
final
SortedSet
<
E
>
ss
;
SynchronizedSortedSet
(
SortedSet
<
E
>
s
)
{
super
(
s
);
...
...
@@ -1778,31 +1778,31 @@ public class Collections {
}
public
Comparator
<?
super
E
>
comparator
()
{
synchronized
(
mutex
)
{
return
ss
.
comparator
();}
synchronized
(
mutex
)
{
return
ss
.
comparator
();}
}
public
SortedSet
<
E
>
subSet
(
E
fromElement
,
E
toElement
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedSortedSet
<
E
>(
ss
.
subSet
(
fromElement
,
toElement
),
mutex
);
}
}
public
SortedSet
<
E
>
headSet
(
E
toElement
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedSortedSet
<
E
>(
ss
.
headSet
(
toElement
),
mutex
);
}
}
public
SortedSet
<
E
>
tailSet
(
E
fromElement
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedSortedSet
<
E
>(
ss
.
tailSet
(
fromElement
),
mutex
);
}
}
public
E
first
()
{
synchronized
(
mutex
)
{
return
ss
.
first
();}
synchronized
(
mutex
)
{
return
ss
.
first
();}
}
public
E
last
()
{
synchronized
(
mutex
)
{
return
ss
.
last
();}
synchronized
(
mutex
)
{
return
ss
.
last
();}
}
}
...
...
@@ -1817,7 +1817,7 @@ public class Collections {
* <pre>
* List list = Collections.synchronizedList(new ArrayList());
* ...
* synchronized(list) {
* synchronized
(list) {
* Iterator i = list.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -1863,34 +1863,34 @@ public class Collections {
}
public
boolean
equals
(
Object
o
)
{
synchronized
(
mutex
)
{
return
list
.
equals
(
o
);}
synchronized
(
mutex
)
{
return
list
.
equals
(
o
);}
}
public
int
hashCode
()
{
synchronized
(
mutex
)
{
return
list
.
hashCode
();}
synchronized
(
mutex
)
{
return
list
.
hashCode
();}
}
public
E
get
(
int
index
)
{
synchronized
(
mutex
)
{
return
list
.
get
(
index
);}
synchronized
(
mutex
)
{
return
list
.
get
(
index
);}
}
public
E
set
(
int
index
,
E
element
)
{
synchronized
(
mutex
)
{
return
list
.
set
(
index
,
element
);}
synchronized
(
mutex
)
{
return
list
.
set
(
index
,
element
);}
}
public
void
add
(
int
index
,
E
element
)
{
synchronized
(
mutex
)
{
list
.
add
(
index
,
element
);}
synchronized
(
mutex
)
{
list
.
add
(
index
,
element
);}
}
public
E
remove
(
int
index
)
{
synchronized
(
mutex
)
{
return
list
.
remove
(
index
);}
synchronized
(
mutex
)
{
return
list
.
remove
(
index
);}
}
public
int
indexOf
(
Object
o
)
{
synchronized
(
mutex
)
{
return
list
.
indexOf
(
o
);}
synchronized
(
mutex
)
{
return
list
.
indexOf
(
o
);}
}
public
int
lastIndexOf
(
Object
o
)
{
synchronized
(
mutex
)
{
return
list
.
lastIndexOf
(
o
);}
synchronized
(
mutex
)
{
return
list
.
lastIndexOf
(
o
);}
}
public
boolean
addAll
(
int
index
,
Collection
<?
extends
E
>
c
)
{
synchronized
(
mutex
)
{
return
list
.
addAll
(
index
,
c
);}
synchronized
(
mutex
)
{
return
list
.
addAll
(
index
,
c
);}
}
public
ListIterator
<
E
>
listIterator
()
{
...
...
@@ -1902,7 +1902,7 @@ public class Collections {
}
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedList
<
E
>(
list
.
subList
(
fromIndex
,
toIndex
),
mutex
);
}
...
...
@@ -1943,7 +1943,7 @@ public class Collections {
}
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedRandomAccessList
<
E
>(
list
.
subList
(
fromIndex
,
toIndex
),
mutex
);
}
...
...
@@ -1975,7 +1975,7 @@ public class Collections {
* ...
* Set s = m.keySet(); // Needn't be in synchronized block
* ...
* synchronized(m) { // Synchronizing on m, not s!
* synchronized
(m) { // Synchronizing on m, not s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -2016,32 +2016,32 @@ public class Collections {
}
public
int
size
()
{
synchronized
(
mutex
)
{
return
m
.
size
();}
synchronized
(
mutex
)
{
return
m
.
size
();}
}
public
boolean
isEmpty
()
{
synchronized
(
mutex
)
{
return
m
.
isEmpty
();}
synchronized
(
mutex
)
{
return
m
.
isEmpty
();}
}
public
boolean
containsKey
(
Object
key
)
{
synchronized
(
mutex
)
{
return
m
.
containsKey
(
key
);}
synchronized
(
mutex
)
{
return
m
.
containsKey
(
key
);}
}
public
boolean
containsValue
(
Object
value
)
{
synchronized
(
mutex
)
{
return
m
.
containsValue
(
value
);}
synchronized
(
mutex
)
{
return
m
.
containsValue
(
value
);}
}
public
V
get
(
Object
key
)
{
synchronized
(
mutex
)
{
return
m
.
get
(
key
);}
synchronized
(
mutex
)
{
return
m
.
get
(
key
);}
}
public
V
put
(
K
key
,
V
value
)
{
synchronized
(
mutex
)
{
return
m
.
put
(
key
,
value
);}
synchronized
(
mutex
)
{
return
m
.
put
(
key
,
value
);}
}
public
V
remove
(
Object
key
)
{
synchronized
(
mutex
)
{
return
m
.
remove
(
key
);}
synchronized
(
mutex
)
{
return
m
.
remove
(
key
);}
}
public
void
putAll
(
Map
<?
extends
K
,
?
extends
V
>
map
)
{
synchronized
(
mutex
)
{
m
.
putAll
(
map
);}
synchronized
(
mutex
)
{
m
.
putAll
(
map
);}
}
public
void
clear
()
{
synchronized
(
mutex
)
{
m
.
clear
();}
synchronized
(
mutex
)
{
m
.
clear
();}
}
private
transient
Set
<
K
>
keySet
=
null
;
...
...
@@ -2049,7 +2049,7 @@ public class Collections {
private
transient
Collection
<
V
>
values
=
null
;
public
Set
<
K
>
keySet
()
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
if
(
keySet
==
null
)
keySet
=
new
SynchronizedSet
<
K
>(
m
.
keySet
(),
mutex
);
return
keySet
;
...
...
@@ -2057,7 +2057,7 @@ public class Collections {
}
public
Set
<
Map
.
Entry
<
K
,
V
>>
entrySet
()
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
if
(
entrySet
==
null
)
entrySet
=
new
SynchronizedSet
<
Map
.
Entry
<
K
,
V
>>(
m
.
entrySet
(),
mutex
);
return
entrySet
;
...
...
@@ -2065,7 +2065,7 @@ public class Collections {
}
public
Collection
<
V
>
values
()
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
if
(
values
==
null
)
values
=
new
SynchronizedCollection
<
V
>(
m
.
values
(),
mutex
);
return
values
;
...
...
@@ -2073,16 +2073,16 @@ public class Collections {
}
public
boolean
equals
(
Object
o
)
{
synchronized
(
mutex
)
{
return
m
.
equals
(
o
);}
synchronized
(
mutex
)
{
return
m
.
equals
(
o
);}
}
public
int
hashCode
()
{
synchronized
(
mutex
)
{
return
m
.
hashCode
();}
synchronized
(
mutex
)
{
return
m
.
hashCode
();}
}
public
String
toString
()
{
synchronized
(
mutex
)
{
return
m
.
toString
();}
synchronized
(
mutex
)
{
return
m
.
toString
();}
}
private
void
writeObject
(
ObjectOutputStream
s
)
throws
IOException
{
synchronized
(
mutex
)
{
s
.
defaultWriteObject
();}
synchronized
(
mutex
)
{
s
.
defaultWriteObject
();}
}
}
...
...
@@ -2101,7 +2101,7 @@ public class Collections {
* ...
* Set s = m.keySet(); // Needn't be in synchronized block
* ...
* synchronized(m) { // Synchronizing on m, not s!
* synchronized
(m) { // Synchronizing on m, not s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -2114,7 +2114,7 @@ public class Collections {
* ...
* Set s2 = m2.keySet(); // Needn't be in synchronized block
* ...
* synchronized(m) { // Synchronizing on m, not m2 or s2!
* synchronized
(m) { // Synchronizing on m, not m2 or s2!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
...
...
@@ -2154,31 +2154,31 @@ public class Collections {
}
public
Comparator
<?
super
K
>
comparator
()
{
synchronized
(
mutex
)
{
return
sm
.
comparator
();}
synchronized
(
mutex
)
{
return
sm
.
comparator
();}
}
public
SortedMap
<
K
,
V
>
subMap
(
K
fromKey
,
K
toKey
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedSortedMap
<
K
,
V
>(
sm
.
subMap
(
fromKey
,
toKey
),
mutex
);
}
}
public
SortedMap
<
K
,
V
>
headMap
(
K
toKey
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedSortedMap
<
K
,
V
>(
sm
.
headMap
(
toKey
),
mutex
);
}
}
public
SortedMap
<
K
,
V
>
tailMap
(
K
fromKey
)
{
synchronized
(
mutex
)
{
synchronized
(
mutex
)
{
return
new
SynchronizedSortedMap
<
K
,
V
>(
sm
.
tailMap
(
fromKey
),
mutex
);
}
}
public
K
firstKey
()
{
synchronized
(
mutex
)
{
return
sm
.
firstKey
();}
synchronized
(
mutex
)
{
return
sm
.
firstKey
();}
}
public
K
lastKey
()
{
synchronized
(
mutex
)
{
return
sm
.
lastKey
();}
synchronized
(
mutex
)
{
return
sm
.
lastKey
();}
}
}
...
...
@@ -3317,7 +3317,7 @@ public class Collections {
{
private
static
final
long
serialVersionUID
=
3193687207550431679L
;
final
private
E
element
;
private
final
E
element
;
SingletonSet
(
E
e
)
{
element
=
e
;}
...
...
@@ -3448,7 +3448,7 @@ public class Collections {
* @param o the element to appear repeatedly in the returned list.
* @return an immutable list consisting of <tt>n</tt> copies of the
* specified object.
* @throws IllegalArgumentException if
n < 0.
* @throws IllegalArgumentException if
{@code n < 0}
* @see List#addAll(Collection)
* @see List#addAll(int, Collection)
*/
...
...
src/share/classes/java/util/ComparableTimSort.java
浏览文件 @
3459dfdc
...
...
@@ -207,7 +207,7 @@ class ComparableTimSort {
* @param lo the index of the first element in the range to be sorted
* @param hi the index after the last element in the range to be sorted
* @param start the index of the first element in the range that is
* not already known to be sorted (
@code lo <= start <= hi}
* not already known to be sorted (
{@code lo <= start <= hi})
*/
@SuppressWarnings
(
"fallthrough"
)
private
static
void
binarySort
(
Object
[]
a
,
int
lo
,
int
hi
,
int
start
)
{
...
...
@@ -245,7 +245,7 @@ class ComparableTimSort {
*/
int
n
=
start
-
left
;
// The number of elements to move
// Switch is just an optimization for arraycopy in default case
switch
(
n
)
{
switch
(
n
)
{
case
2
:
a
[
left
+
2
]
=
a
[
left
+
1
];
case
1
:
a
[
left
+
1
]
=
a
[
left
];
break
;
...
...
@@ -275,7 +275,7 @@ class ComparableTimSort {
* @param a the array in which a run is to be counted and possibly reversed
* @param lo index of the first element in the run
* @param hi index after the last element that may be contained in the run.
It is required that
@code{
lo < hi}.
It is required that
{@code
lo < hi}.
* @return the length of the run beginning at the specified position in
* the specified array
*/
...
...
@@ -288,7 +288,7 @@ class ComparableTimSort {
// Find end of run, and reverse range if descending
if
(((
Comparable
)
a
[
runHi
++]).
compareTo
(
a
[
lo
])
<
0
)
{
// Descending
while
(
runHi
<
hi
&&
((
Comparable
)
a
[
runHi
]).
compareTo
(
a
[
runHi
-
1
])
<
0
)
while
(
runHi
<
hi
&&
((
Comparable
)
a
[
runHi
]).
compareTo
(
a
[
runHi
-
1
])
<
0
)
runHi
++;
reverseRange
(
a
,
lo
,
runHi
);
}
else
{
// Ascending
...
...
src/share/classes/java/util/Random.java
浏览文件 @
3459dfdc
...
...
@@ -77,9 +77,9 @@ class Random implements java.io.Serializable {
*/
private
final
AtomicLong
seed
;
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
/**
* Creates a new random number generator. This constructor sets
...
...
@@ -285,7 +285,7 @@ class Random implements java.io.Serializable {
* @return the next pseudorandom, uniformly distributed {@code int}
* value between {@code 0} (inclusive) and {@code n} (exclusive)
* from this random number generator's sequence
* @
exception
IllegalArgumentException if n is not positive
* @
throws
IllegalArgumentException if n is not positive
* @since 1.2
*/
...
...
src/share/classes/java/util/Stack.java
浏览文件 @
3459dfdc
...
...
@@ -75,7 +75,7 @@ class Stack<E> extends Vector<E> {
*
* @return The object at the top of this stack (the last item
* of the <tt>Vector</tt> object).
* @
exception
EmptyStackException if this stack is empty.
* @
throws
EmptyStackException if this stack is empty.
*/
public
synchronized
E
pop
()
{
E
obj
;
...
...
@@ -93,7 +93,7 @@ class Stack<E> extends Vector<E> {
*
* @return the object at the top of this stack (the last item
* of the <tt>Vector</tt> object).
* @
exception
EmptyStackException if this stack is empty.
* @
throws
EmptyStackException if this stack is empty.
*/
public
synchronized
E
peek
()
{
int
len
=
size
();
...
...
src/share/classes/java/util/TimSort.java
浏览文件 @
3459dfdc
...
...
@@ -239,7 +239,7 @@ class TimSort<T> {
* @param lo the index of the first element in the range to be sorted
* @param hi the index after the last element in the range to be sorted
* @param start the index of the first element in the range that is
* not already known to be sorted (
@code lo <= start <= hi}
* not already known to be sorted (
{@code lo <= start <= hi})
* @param c comparator to used for the sort
*/
@SuppressWarnings
(
"fallthrough"
)
...
...
@@ -278,7 +278,7 @@ class TimSort<T> {
*/
int
n
=
start
-
left
;
// The number of elements to move
// Switch is just an optimization for arraycopy in default case
switch
(
n
)
{
switch
(
n
)
{
case
2
:
a
[
left
+
2
]
=
a
[
left
+
1
];
case
1
:
a
[
left
+
1
]
=
a
[
left
];
break
;
...
...
@@ -308,7 +308,7 @@ class TimSort<T> {
* @param a the array in which a run is to be counted and possibly reversed
* @param lo index of the first element in the run
* @param hi index after the last element that may be contained in the run.
It is required that
@code{
lo < hi}.
It is required that
{@code
lo < hi}.
* @param c the comparator to used for the sort
* @return the length of the run beginning at the specified position in
* the specified array
...
...
@@ -322,7 +322,7 @@ class TimSort<T> {
// Find end of run, and reverse range if descending
if
(
c
.
compare
(
a
[
runHi
++],
a
[
lo
])
<
0
)
{
// Descending
while
(
runHi
<
hi
&&
c
.
compare
(
a
[
runHi
],
a
[
runHi
-
1
])
<
0
)
while
(
runHi
<
hi
&&
c
.
compare
(
a
[
runHi
],
a
[
runHi
-
1
])
<
0
)
runHi
++;
reverseRange
(
a
,
lo
,
runHi
);
}
else
{
// Ascending
...
...
src/share/classes/java/util/TreeMap.java
浏览文件 @
3459dfdc
...
...
@@ -1056,11 +1056,11 @@ public class TreeMap<K,V>
public
Comparator
<?
super
E
>
comparator
()
{
return
m
.
comparator
();
}
public
E
pollFirst
()
{
Map
.
Entry
<
E
,
Object
>
e
=
m
.
pollFirstEntry
();
return
e
==
null
?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
public
E
pollLast
()
{
Map
.
Entry
<
E
,
Object
>
e
=
m
.
pollLastEntry
();
return
e
==
null
?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
public
boolean
remove
(
Object
o
)
{
int
oldSize
=
size
();
...
...
@@ -1196,7 +1196,7 @@ public class TreeMap<K,V>
* Test two values for equality. Differs from o1.equals(o2) only in
* that it copes with {@code null} o1 properly.
*/
final
static
boolean
valEquals
(
Object
o1
,
Object
o2
)
{
static
final
boolean
valEquals
(
Object
o1
,
Object
o2
)
{
return
(
o1
==
null
?
o2
==
null
:
o1
.
equals
(
o2
));
}
...
...
@@ -1204,7 +1204,7 @@ public class TreeMap<K,V>
* Return SimpleImmutableEntry for entry, or null if null
*/
static
<
K
,
V
>
Map
.
Entry
<
K
,
V
>
exportEntry
(
TreeMap
.
Entry
<
K
,
V
>
e
)
{
return
e
==
null
?
null
:
return
(
e
==
null
)
?
null
:
new
AbstractMap
.
SimpleImmutableEntry
<
K
,
V
>(
e
);
}
...
...
@@ -1212,7 +1212,7 @@ public class TreeMap<K,V>
* Return key for entry, or null if null
*/
static
<
K
,
V
>
K
keyOrNull
(
TreeMap
.
Entry
<
K
,
V
>
e
)
{
return
e
==
null
?
null
:
e
.
key
;
return
(
e
==
null
)
?
null
:
e
.
key
;
}
/**
...
...
@@ -1237,7 +1237,7 @@ public class TreeMap<K,V>
/**
* @serial include
*/
static
abstract
class
NavigableSubMap
<
K
,
V
>
extends
AbstractMap
<
K
,
V
>
abstract
static
class
NavigableSubMap
<
K
,
V
>
extends
AbstractMap
<
K
,
V
>
implements
NavigableMap
<
K
,
V
>,
java
.
io
.
Serializable
{
/**
* The backing map.
...
...
@@ -1412,11 +1412,11 @@ public class TreeMap<K,V>
}
public
final
V
get
(
Object
key
)
{
return
!
inRange
(
key
)?
null
:
m
.
get
(
key
);
return
!
inRange
(
key
)
?
null
:
m
.
get
(
key
);
}
public
final
V
remove
(
Object
key
)
{
return
!
inRange
(
key
)
?
null
:
m
.
remove
(
key
);
return
!
inRange
(
key
)
?
null
:
m
.
remove
(
key
);
}
public
final
Map
.
Entry
<
K
,
V
>
ceilingEntry
(
K
key
)
{
...
...
@@ -1559,7 +1559,8 @@ public class TreeMap<K,V>
if
(!
inRange
(
key
))
return
false
;
TreeMap
.
Entry
<
K
,
V
>
node
=
m
.
getEntry
(
key
);
if
(
node
!=
null
&&
valEquals
(
node
.
getValue
(),
entry
.
getValue
())){
if
(
node
!=
null
&&
valEquals
(
node
.
getValue
(),
entry
.
getValue
()))
{
m
.
deleteEntry
(
node
);
return
true
;
}
...
...
@@ -1724,7 +1725,7 @@ public class TreeMap<K,V>
false
,
toKey
,
inclusive
);
}
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
){
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
if
(!
inRange
(
fromKey
,
inclusive
))
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
return
new
AscendingSubMap
(
m
,
...
...
@@ -1805,7 +1806,7 @@ public class TreeMap<K,V>
toEnd
,
hi
,
hiInclusive
);
}
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
){
public
NavigableMap
<
K
,
V
>
tailMap
(
K
fromKey
,
boolean
inclusive
)
{
if
(!
inRange
(
fromKey
,
inclusive
))
throw
new
IllegalArgumentException
(
"fromKey out of range"
);
return
new
DescendingSubMap
(
m
,
...
...
@@ -2143,7 +2144,7 @@ public class TreeMap<K,V>
// If strictly internal, copy successor's element to p and then make p
// point to successor.
if
(
p
.
left
!=
null
&&
p
.
right
!=
null
)
{
Entry
<
K
,
V
>
s
=
successor
(
p
);
Entry
<
K
,
V
>
s
=
successor
(
p
);
p
.
key
=
s
.
key
;
p
.
value
=
s
.
value
;
p
=
s
;
...
...
src/share/classes/java/util/TreeSet.java
浏览文件 @
3459dfdc
...
...
@@ -452,7 +452,7 @@ public class TreeSet<E> extends AbstractSet<E>
*/
public
E
pollFirst
()
{
Map
.
Entry
<
E
,?>
e
=
m
.
pollFirstEntry
();
return
(
e
==
null
)?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
/**
...
...
@@ -460,7 +460,7 @@ public class TreeSet<E> extends AbstractSet<E>
*/
public
E
pollLast
()
{
Map
.
Entry
<
E
,?>
e
=
m
.
pollLastEntry
();
return
(
e
==
null
)?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
/**
...
...
src/share/classes/java/util/Vector.java
浏览文件 @
3459dfdc
src/share/classes/java/util/concurrent/AbstractExecutorService.java
浏览文件 @
3459dfdc
...
...
@@ -51,20 +51,20 @@ import java.util.*;
* <p> <b>Extension example</b>. Here is a sketch of a class
* that customizes {@link ThreadPoolExecutor} to use
* a <tt>CustomTask</tt> class instead of the default <tt>FutureTask</tt>:
*
<pre>
*
<pre> {@code
* public class CustomThreadPoolExecutor extends ThreadPoolExecutor {
*
* static class CustomTask
<V> implements RunnableFuture<V>
{...}
* static class CustomTask
<V> implements RunnableFuture<V>
{...}
*
* protected
<V> RunnableFuture<V> newTaskFor(Callable<V>
c) {
* return new CustomTask
<V>
(c);
* protected
<V> RunnableFuture<V> newTaskFor(Callable<V>
c) {
* return new CustomTask
<V>
(c);
* }
* protected
<V> RunnableFuture<V>
newTaskFor(Runnable r, V v) {
* return new CustomTask
<V>
(r, v);
* protected
<V> RunnableFuture<V>
newTaskFor(Runnable r, V v) {
* return new CustomTask
<V>
(r, v);
* }
* // ... add constructors, etc.
* }
*
</pre>
* }
}</pre>
*
* @since 1.5
* @author Doug Lea
*/
...
...
@@ -106,7 +106,7 @@ public abstract class AbstractExecutorService implements ExecutorService {
*/
public
Future
<?>
submit
(
Runnable
task
)
{
if
(
task
==
null
)
throw
new
NullPointerException
();
RunnableFuture
<
Object
>
ftask
=
newTaskFor
(
task
,
null
);
RunnableFuture
<
Void
>
ftask
=
newTaskFor
(
task
,
null
);
execute
(
ftask
);
return
ftask
;
}
...
...
@@ -158,7 +158,7 @@ public abstract class AbstractExecutorService implements ExecutorService {
// Record exceptions so that if we fail to obtain any
// result, we can throw the last exception we got.
ExecutionException
ee
=
null
;
long
lastTime
=
(
timed
)
?
System
.
nanoTime
()
:
0
;
long
lastTime
=
timed
?
System
.
nanoTime
()
:
0
;
Iterator
<?
extends
Callable
<
T
>>
it
=
tasks
.
iterator
();
// Start one task for sure; the rest incrementally
...
...
@@ -191,8 +191,6 @@ public abstract class AbstractExecutorService implements ExecutorService {
--
active
;
try
{
return
f
.
get
();
}
catch
(
InterruptedException
ie
)
{
throw
ie
;
}
catch
(
ExecutionException
eex
)
{
ee
=
eex
;
}
catch
(
RuntimeException
rex
)
{
...
...
src/share/classes/java/util/concurrent/ConcurrentHashMap.java
浏览文件 @
3459dfdc
src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
浏览文件 @
3459dfdc
...
...
@@ -38,7 +38,6 @@ package java.util.concurrent;
import
java.util.AbstractCollection
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.ConcurrentModificationException
;
import
java.util.Deque
;
import
java.util.Iterator
;
import
java.util.NoSuchElementException
;
...
...
@@ -212,7 +211,7 @@ public class ConcurrentLinkedDeque<E>
* The actual representation we use is that p.next == p means to
* goto the first node (which in turn is reached by following prev
* pointers from head), and p.next == null && p.prev == p means
* that the iteration is at an end and that p is a (
final static
)
* that the iteration is at an end and that p is a (
static final
)
* dummy node, NEXT_TERMINATOR, and not the last active node.
* Finishing the iteration when encountering such a TERMINATOR is
* good enough for read-only traversals, so such traversals can use
...
...
@@ -271,7 +270,7 @@ public class ConcurrentLinkedDeque<E>
*/
private
transient
volatile
Node
<
E
>
tail
;
private
final
static
Node
<
Object
>
PREV_TERMINATOR
,
NEXT_TERMINATOR
;
private
static
final
Node
<
Object
>
PREV_TERMINATOR
,
NEXT_TERMINATOR
;
static
{
PREV_TERMINATOR
=
new
Node
<
Object
>(
null
);
...
...
@@ -401,7 +400,7 @@ public class ConcurrentLinkedDeque<E>
}
}
private
final
static
int
HOPS
=
2
;
private
static
final
int
HOPS
=
2
;
/**
* Unlinks non-null node x.
...
...
@@ -871,7 +870,7 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the front of this deque.
*
* @throws NullPointerException
{@inheritDoc}
* @throws NullPointerException
if the specified element is null
*/
public
void
addFirst
(
E
e
)
{
linkFirst
(
e
);
...
...
@@ -882,7 +881,7 @@ public class ConcurrentLinkedDeque<E>
*
* <p>This method is equivalent to {@link #add}.
*
* @throws NullPointerException
{@inheritDoc}
* @throws NullPointerException
if the specified element is null
*/
public
void
addLast
(
E
e
)
{
linkLast
(
e
);
...
...
@@ -892,7 +891,7 @@ public class ConcurrentLinkedDeque<E>
* Inserts the specified element at the front of this deque.
*
* @return {@code true} always
* @throws NullPointerException
{@inheritDoc}
* @throws NullPointerException
if the specified element is null
*/
public
boolean
offerFirst
(
E
e
)
{
linkFirst
(
e
);
...
...
@@ -905,7 +904,7 @@ public class ConcurrentLinkedDeque<E>
* <p>This method is equivalent to {@link #add}.
*
* @return {@code true} always
* @throws NullPointerException
{@inheritDoc}
* @throws NullPointerException
if the specified element is null
*/
public
boolean
offerLast
(
E
e
)
{
linkLast
(
e
);
...
...
@@ -1016,7 +1015,7 @@ public class ConcurrentLinkedDeque<E>
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is
{@code null}
* @throws NullPointerException if the specified element is
null
*/
public
boolean
removeFirstOccurrence
(
Object
o
)
{
checkNotNull
(
o
);
...
...
@@ -1037,7 +1036,7 @@ public class ConcurrentLinkedDeque<E>
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is
{@code null}
* @throws NullPointerException if the specified element is
null
*/
public
boolean
removeLastOccurrence
(
Object
o
)
{
checkNotNull
(
o
);
...
...
@@ -1110,7 +1109,7 @@ public class ConcurrentLinkedDeque<E>
*
* @param o element to be removed from this deque, if present
* @return {@code true} if the deque contained the specified element
* @throws NullPointerException if the specified element is
{@code null}
* @throws NullPointerException if the specified element is
null
*/
public
boolean
remove
(
Object
o
)
{
return
removeFirstOccurrence
(
o
);
...
...
@@ -1165,7 +1164,7 @@ public class ConcurrentLinkedDeque<E>
beginningOfTheEnd
.
lazySetPrev
(
p
);
// CAS piggyback
if
(
p
.
casNext
(
null
,
beginningOfTheEnd
))
{
// Successful CAS is the linearization point
// for all elements to be added to this
que
ue.
// for all elements to be added to this
deq
ue.
if
(!
casTail
(
t
,
last
))
{
// Try a little harder to update tail,
// since we may be adding many elements.
...
...
@@ -1251,12 +1250,12 @@ public class ConcurrentLinkedDeque<E>
* Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
*
* <p>The returned
{@code Iterator}
is a "weakly consistent" iterator that
* <p>The returned
iterator
is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
*
and guarantees to traverse elements as they existed upon
*
construction of the iterator, and may (but is not guaranteed to)
*
reflect any modifications
subsequent to construction.
* ConcurrentModificationException},
and guarantees to traverse
*
elements as they existed upon construction of the iterator, and
*
may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in proper sequence
*/
...
...
@@ -1269,12 +1268,12 @@ public class ConcurrentLinkedDeque<E>
* sequential order. The elements will be returned in order from
* last (tail) to first (head).
*
* <p>The returned
{@code Iterator}
is a "weakly consistent" iterator that
* <p>The returned
iterator
is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
*
and guarantees to traverse elements as they existed upon
*
construction of the iterator, and may (but is not guaranteed to)
*
reflect any modifications
subsequent to construction.
* ConcurrentModificationException},
and guarantees to traverse
*
elements as they existed upon construction of the iterator, and
*
may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in reverse order
*/
...
...
src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
浏览文件 @
3459dfdc
...
...
@@ -65,8 +65,8 @@ import java.util.Queue;
* <p>Iterators are <i>weakly consistent</i>, returning elements
* reflecting the state of the queue at some point at or since the
* creation of the iterator. They do <em>not</em> throw {@link
*
ConcurrentModificationException}, and may proceed concurrently with
* other operations. Elements contained in the queue since the creation
*
java.util.ConcurrentModificationException}, and may proceed concurrently
*
with
other operations. Elements contained in the queue since the creation
* of the iterator will be returned exactly once.
*
* <p>Beware that, unlike in most collections, the {@code size} method
...
...
@@ -634,12 +634,12 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
*
* <p>The returned
{@code Iterator}
is a "weakly consistent" iterator that
* <p>The returned
iterator
is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
*
and guarantees to traverse elements as they existed upon
*
construction of the iterator, and may (but is not guaranteed to)
*
reflect any modifications
subsequent to construction.
* ConcurrentModificationException},
and guarantees to traverse
*
elements as they existed upon construction of the iterator, and
*
may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this queue in proper sequence
*/
...
...
src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
浏览文件 @
3459dfdc
...
...
@@ -362,12 +362,12 @@ public class ConcurrentSkipListSet<E>
public
E
pollFirst
()
{
Map
.
Entry
<
E
,
Object
>
e
=
m
.
pollFirstEntry
();
return
e
==
null
?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
public
E
pollLast
()
{
Map
.
Entry
<
E
,
Object
>
e
=
m
.
pollLastEntry
();
return
e
==
null
?
null
:
e
.
getKey
();
return
(
e
==
null
)
?
null
:
e
.
getKey
();
}
...
...
src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
浏览文件 @
3459dfdc
...
...
@@ -547,7 +547,7 @@ public class CopyOnWriteArrayList<E>
* @param fromIndex index of first element to be removed
* @param toIndex index after last element to be removed
* @throws IndexOutOfBoundsException if fromIndex or toIndex out of range
* (@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex})
* (
{
@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex})
*/
private
void
removeRange
(
int
fromIndex
,
int
toIndex
)
{
final
ReentrantLock
lock
=
this
.
lock
;
...
...
@@ -989,7 +989,7 @@ public class CopyOnWriteArrayList<E>
}
private
static
class
COWIterator
<
E
>
implements
ListIterator
<
E
>
{
/** Snapshot of the array *
*
/
/** Snapshot of the array */
private
final
Object
[]
snapshot
;
/** Index of element to be returned by subsequent call to next. */
private
int
cursor
;
...
...
src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java
浏览文件 @
3459dfdc
...
...
@@ -59,12 +59,12 @@ import java.util.*;
* copy-on-write set to maintain a set of Handler objects that
* perform some action upon state updates.
*
*
<pre>
*
<pre> {@code
* class Handler { void handle(); ... }
*
* class X {
*
private final CopyOnWriteArraySet<Handler>
handlers
*
= new CopyOnWriteArraySet<Handler>
();
*
private final CopyOnWriteArraySet<Handler>
handlers
*
= new CopyOnWriteArraySet<Handler>
();
* public void addHandler(Handler h) { handlers.add(h); }
*
* private long internalState;
...
...
@@ -75,8 +75,7 @@ import java.util.*;
* for (Handler handler : handlers)
* handler.handle();
* }
* }
* </pre>
* }}</pre>
*
* <p>This class is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
...
...
src/share/classes/java/util/concurrent/CountDownLatch.java
浏览文件 @
3459dfdc
...
...
@@ -175,7 +175,7 @@ public class CountDownLatch {
}
protected
int
tryAcquireShared
(
int
acquires
)
{
return
getState
()
==
0
?
1
:
-
1
;
return
(
getState
()
==
0
)
?
1
:
-
1
;
}
protected
boolean
tryReleaseShared
(
int
releases
)
{
...
...
src/share/classes/java/util/concurrent/DelayQueue.java
浏览文件 @
3459dfdc
...
...
@@ -482,12 +482,14 @@ public class DelayQueue<E extends Delayed> extends AbstractQueue<E>
/**
* Returns an iterator over all the elements (both expired and
* unexpired) in this queue. The iterator does not return the
* elements in any particular order. The returned
* <tt>Iterator</tt> is a "weakly consistent" iterator that will
* never throw {@link ConcurrentModificationException}, and
* guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed
* to) reflect any modifications subsequent to construction.
* elements in any particular order.
*
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this queue
*/
...
...
src/share/classes/java/util/concurrent/Exchanger.java
浏览文件 @
3459dfdc
...
...
@@ -355,7 +355,9 @@ public class Exchanger<V> {
else
if
(
y
==
null
&&
// Try to occupy
slot
.
compareAndSet
(
null
,
me
))
{
if
(
index
==
0
)
// Blocking wait for slot 0
return
timed
?
awaitNanos
(
me
,
slot
,
nanos
):
await
(
me
,
slot
);
return
timed
?
awaitNanos
(
me
,
slot
,
nanos
)
:
await
(
me
,
slot
);
Object
v
=
spinWait
(
me
,
slot
);
// Spin wait for non-0
if
(
v
!=
CANCEL
)
return
v
;
...
...
@@ -597,8 +599,8 @@ public class Exchanger<V> {
* dormant until one of two things happens:
* <ul>
* <li>Some other thread enters the exchange; or
* <li>Some other thread {@linkplain Thread#interrupt interrupts}
the current
* thread.
* <li>Some other thread {@linkplain Thread#interrupt interrupts}
* th
e current th
read.
* </ul>
* <p>If the current thread:
* <ul>
...
...
@@ -616,7 +618,7 @@ public class Exchanger<V> {
*/
public
V
exchange
(
V
x
)
throws
InterruptedException
{
if
(!
Thread
.
interrupted
())
{
Object
v
=
doExchange
(
x
==
null
?
NULL_ITEM
:
x
,
false
,
0
);
Object
v
=
doExchange
(
(
x
==
null
)
?
NULL_ITEM
:
x
,
false
,
0
);
if
(
v
==
NULL_ITEM
)
return
null
;
if
(
v
!=
CANCEL
)
...
...
@@ -671,7 +673,7 @@ public class Exchanger<V> {
public
V
exchange
(
V
x
,
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
,
TimeoutException
{
if
(!
Thread
.
interrupted
())
{
Object
v
=
doExchange
(
x
==
null
?
NULL_ITEM
:
x
,
Object
v
=
doExchange
(
(
x
==
null
)
?
NULL_ITEM
:
x
,
true
,
unit
.
toNanos
(
timeout
));
if
(
v
==
NULL_ITEM
)
return
null
;
...
...
src/share/classes/java/util/concurrent/Executor.java
浏览文件 @
3459dfdc
...
...
@@ -79,9 +79,9 @@ package java.util.concurrent;
* serializes the submission of tasks to a second executor,
* illustrating a composite executor.
*
*
<pre>
*
<pre> {@code
* class SerialExecutor implements Executor {
*
final Queue<Runnable> tasks = new ArrayDeque<Runnable>
();
*
final Queue<Runnable> tasks = new ArrayDeque<Runnable>
();
* final Executor executor;
* Runnable active;
*
...
...
@@ -109,7 +109,7 @@ package java.util.concurrent;
* executor.execute(active);
* }
* }
* }</pre>
* }
}
</pre>
*
* The <tt>Executor</tt> implementations provided in this package
* implement {@link ExecutorService}, which is a more extensive
...
...
src/share/classes/java/util/concurrent/ExecutorCompletionService.java
浏览文件 @
3459dfdc
...
...
@@ -197,7 +197,8 @@ public class ExecutorCompletionService<V> implements CompletionService<V> {
return
completionQueue
.
poll
();
}
public
Future
<
V
>
poll
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
public
Future
<
V
>
poll
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
return
completionQueue
.
poll
(
timeout
,
unit
);
}
...
...
src/share/classes/java/util/concurrent/Executors.java
浏览文件 @
3459dfdc
...
...
@@ -83,7 +83,7 @@ public class Executors {
*
* @param nThreads the number of threads in the pool
* @return the newly created thread pool
* @throws IllegalArgumentException if
<tt>nThreads <= 0</tt>
* @throws IllegalArgumentException if
{@code nThreads <= 0}
*/
public
static
ExecutorService
newFixedThreadPool
(
int
nThreads
)
{
return
new
ThreadPoolExecutor
(
nThreads
,
nThreads
,
...
...
@@ -108,7 +108,7 @@ public class Executors {
* @param threadFactory the factory to use when creating new threads
* @return the newly created thread pool
* @throws NullPointerException if threadFactory is null
* @throws IllegalArgumentException if
<tt>nThreads <= 0</tt>
* @throws IllegalArgumentException if
{@code nThreads <= 0}
*/
public
static
ExecutorService
newFixedThreadPool
(
int
nThreads
,
ThreadFactory
threadFactory
)
{
return
new
ThreadPoolExecutor
(
nThreads
,
nThreads
,
...
...
@@ -242,7 +242,7 @@ public class Executors {
* @param corePoolSize the number of threads to keep in the pool,
* even if they are idle.
* @return a newly created scheduled thread pool
* @throws IllegalArgumentException if
<tt>corePoolSize < 0</tt>
* @throws IllegalArgumentException if
{@code corePoolSize < 0}
*/
public
static
ScheduledExecutorService
newScheduledThreadPool
(
int
corePoolSize
)
{
return
new
ScheduledThreadPoolExecutor
(
corePoolSize
);
...
...
@@ -256,7 +256,7 @@ public class Executors {
* @param threadFactory the factory to use when the executor
* creates a new thread.
* @return a newly created scheduled thread pool
* @throws IllegalArgumentException if
<tt>corePoolSize < 0</tt>
* @throws IllegalArgumentException if
{@code corePoolSize < 0}
* @throws NullPointerException if threadFactory is null
*/
public
static
ScheduledExecutorService
newScheduledThreadPool
(
...
...
@@ -562,7 +562,7 @@ public class Executors {
DefaultThreadFactory
()
{
SecurityManager
s
=
System
.
getSecurityManager
();
group
=
(
s
!=
null
)?
s
.
getThreadGroup
()
:
group
=
(
s
!=
null
)
?
s
.
getThreadGroup
()
:
Thread
.
currentThread
().
getThreadGroup
();
namePrefix
=
"pool-"
+
poolNumber
.
getAndIncrement
()
+
...
...
src/share/classes/java/util/concurrent/Future.java
浏览文件 @
3459dfdc
...
...
@@ -47,21 +47,21 @@ package java.util.concurrent;
* computation has completed, the computation cannot be cancelled.
* If you would like to use a <tt>Future</tt> for the sake
* of cancellability but not provide a usable result, you can
* declare types of the form
<tt>Future<?></tt>
and
* declare types of the form
{@code Future<?>}
and
* return <tt>null</tt> as a result of the underlying task.
*
* <p>
* <b>Sample Usage</b> (Note that the following classes are all
* made-up.) <p>
*
<pre>
*
<pre> {@code
* interface ArchiveSearcher { String search(String target); }
* class App {
* ExecutorService executor = ...
* ArchiveSearcher searcher = ...
* void showSearch(final String target)
* throws InterruptedException {
* Future
<String>
future
* = executor.submit(new Callable
<String>
() {
* Future
<String>
future
* = executor.submit(new Callable
<String>
() {
* public String call() {
* return searcher.search(target);
* }});
...
...
@@ -70,20 +70,18 @@ package java.util.concurrent;
* displayText(future.get()); // use future
* } catch (ExecutionException ex) { cleanup(); return; }
* }
* }
* </pre>
* }}</pre>
*
* The {@link FutureTask} class is an implementation of <tt>Future</tt> that
* implements <tt>Runnable</tt>, and so may be executed by an <tt>Executor</tt>.
* For example, the above construction with <tt>submit</tt> could be replaced by:
*
<pre>
* FutureTask
<String>
future =
* new FutureTask
<String>(new Callable<String>
() {
*
<pre> {@code
* FutureTask
<String>
future =
* new FutureTask
<String>(new Callable<String>
() {
* public String call() {
* return searcher.search(target);
* }});
* executor.execute(future);
* </pre>
* executor.execute(future);}</pre>
*
* <p>Memory consistency effects: Actions taken by the asynchronous computation
* <a href="package-summary.html#MemoryVisibility"> <i>happen-before</i></a>
...
...
src/share/classes/java/util/concurrent/FutureTask.java
浏览文件 @
3459dfdc
...
...
@@ -85,7 +85,7 @@ public class FutureTask<V> implements RunnableFuture<V> {
* @param result the result to return on successful completion. If
* you don't need a particular result, consider using
* constructions of the form:
*
<tt>Future<?> f = new FutureTask<Object>(runnable, null)</tt>
*
{@code Future<?> f = new FutureTask<Void>(runnable, null)}
* @throws NullPointerException if runnable is null
*/
public
FutureTask
(
Runnable
runnable
,
V
result
)
{
...
...
src/share/classes/java/util/concurrent/LinkedBlockingDeque.java
浏览文件 @
3459dfdc
...
...
@@ -1004,12 +1004,13 @@ public class LinkedBlockingDeque<E>
/**
* Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
* The returned {@code Iterator} is a "weakly consistent" iterator that
*
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
*
and guarantees to traverse elements as they existed upon
*
construction of the iterator, and may (but is not guaranteed to)
*
reflect any modifications
subsequent to construction.
* ConcurrentModificationException},
and guarantees to traverse
*
elements as they existed upon construction of the iterator, and
*
may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in proper sequence
*/
...
...
@@ -1021,12 +1022,13 @@ public class LinkedBlockingDeque<E>
* Returns an iterator over the elements in this deque in reverse
* sequential order. The elements will be returned in order from
* last (tail) to first (head).
* The returned {@code Iterator} is a "weakly consistent" iterator that
*
* <p>The returned iterator is a "weakly consistent" iterator that
* will never throw {@link java.util.ConcurrentModificationException
* ConcurrentModificationException},
*
and guarantees to traverse elements as they existed upon
*
construction of the iterator, and may (but is not guaranteed to)
*
reflect any modifications
subsequent to construction.
* ConcurrentModificationException},
and guarantees to traverse
*
elements as they existed upon construction of the iterator, and
*
may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*/
public
Iterator
<
E
>
descendingIterator
()
{
return
new
DescendingItr
();
...
...
src/share/classes/java/util/concurrent/RecursiveAction.java
浏览文件 @
3459dfdc
...
...
@@ -159,7 +159,9 @@ public abstract class RecursiveAction extends ForkJoinTask<Void> {
protected
abstract
void
compute
();
/**
* Always returns null.
* Always returns {@code null}.
*
* @return {@code null} always
*/
public
final
Void
getRawResult
()
{
return
null
;
}
...
...
src/share/classes/java/util/concurrent/ScheduledExecutorService.java
浏览文件 @
3459dfdc
...
...
@@ -72,7 +72,7 @@ import java.util.*;
* Here is a class with a method that sets up a ScheduledExecutorService
* to beep every ten seconds for an hour:
*
*
<pre>
*
<pre> {@code
* import static java.util.concurrent.TimeUnit.*;
* class BeeperControl {
* private final ScheduledExecutorService scheduler =
...
...
@@ -82,14 +82,13 @@ import java.util.*;
* final Runnable beeper = new Runnable() {
* public void run() { System.out.println("beep"); }
* };
*
final ScheduledFuture<?>
beeperHandle =
*
final ScheduledFuture<?>
beeperHandle =
* scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
* scheduler.schedule(new Runnable() {
* public void run() { beeperHandle.cancel(true); }
* }, 60 * 60, SECONDS);
* }
* }
* </pre>
* }}</pre>
*
* @since 1.5
* @author Doug Lea
...
...
src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java
浏览文件 @
3459dfdc
...
...
@@ -62,8 +62,8 @@ import java.util.*;
* time of cancellation.
*
* <p>Successive executions of a task scheduled via
*
<code>scheduleAtFixedRate</code>
or
*
<code>scheduleWithFixedDelay</code>
do not overlap. While different
*
{@code scheduleAtFixedRate}
or
*
{@code scheduleWithFixedDelay}
do not overlap. While different
* executions may be performed by different threads, the effects of
* prior executions <a
* href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
...
...
src/share/classes/java/util/concurrent/Semaphore.java
浏览文件 @
3459dfdc
...
...
@@ -223,7 +223,7 @@ public class Semaphore implements java.io.Serializable {
/**
* NonFair version
*/
final
static
class
NonfairSync
extends
Sync
{
static
final
class
NonfairSync
extends
Sync
{
private
static
final
long
serialVersionUID
=
-
2694183684443567898L
;
NonfairSync
(
int
permits
)
{
...
...
@@ -238,7 +238,7 @@ public class Semaphore implements java.io.Serializable {
/**
* Fair version
*/
final
static
class
FairSync
extends
Sync
{
static
final
class
FairSync
extends
Sync
{
private
static
final
long
serialVersionUID
=
2014338818796000944L
;
FairSync
(
int
permits
)
{
...
...
@@ -282,7 +282,7 @@ public class Semaphore implements java.io.Serializable {
* else {@code false}
*/
public
Semaphore
(
int
permits
,
boolean
fair
)
{
sync
=
(
fair
)
?
new
FairSync
(
permits
)
:
new
NonfairSync
(
permits
);
sync
=
fair
?
new
FairSync
(
permits
)
:
new
NonfairSync
(
permits
);
}
/**
...
...
src/share/classes/java/util/concurrent/ThreadLocalRandom.java
浏览文件 @
3459dfdc
...
...
@@ -63,9 +63,9 @@ import java.util.Random;
*/
public
class
ThreadLocalRandom
extends
Random
{
// same constants as Random, but must be redeclared because private
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
/**
* The random seed. We can't use super.seed.
...
...
src/share/classes/java/util/concurrent/TimeUnit.java
浏览文件 @
3459dfdc
...
...
@@ -53,12 +53,12 @@ package java.util.concurrent;
* java.util.concurrent.locks.Lock lock} is not available:
*
* <pre> Lock lock = ...;
* if (
lock.tryLock(50L, TimeUnit.MILLISECONDS)
) ...
* if (
lock.tryLock(50L, TimeUnit.MILLISECONDS)
) ...
* </pre>
* while this code will timeout in 50 seconds:
* <pre>
* Lock lock = ...;
* if (
lock.tryLock(50L, TimeUnit.SECONDS)
) ...
* if (
lock.tryLock(50L, TimeUnit.SECONDS)
) ...
* </pre>
*
* Note however, that there is no guarantee that a particular timeout
...
...
@@ -291,7 +291,8 @@ public enum TimeUnit {
abstract
int
excessNanos
(
long
d
,
long
m
);
/**
* Performs a timed <tt>Object.wait</tt> using this time unit.
* Performs a timed {@link Object#wait(long, int) Object.wait}
* using this time unit.
* This is a convenience method that converts timeout arguments
* into the form required by the <tt>Object.wait</tt> method.
*
...
...
@@ -299,18 +300,19 @@ public enum TimeUnit {
* method (see {@link BlockingQueue#poll BlockingQueue.poll})
* using:
*
* <pre> public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException {
* <pre> {@code
* public synchronized Object poll(long timeout, TimeUnit unit)
* throws InterruptedException {
* while (empty) {
* unit.timedWait(this, timeout);
* ...
* }
*
}</pre>
*
}
}</pre>
*
* @param obj the object to wait on
* @param timeout the maximum time to wait. If less than
* or equal to zero, do not wait at all.
* @throws InterruptedException if interrupted while waiting.
* @see Object#wait(long, int)
* @throws InterruptedException if interrupted while waiting
*/
public
void
timedWait
(
Object
obj
,
long
timeout
)
throws
InterruptedException
{
...
...
@@ -322,14 +324,15 @@ public enum TimeUnit {
}
/**
* Performs a timed <tt>Thread.join</tt> using this time unit.
* Performs a timed {@link Thread#join(long, int) Thread.join}
* using this time unit.
* This is a convenience method that converts time arguments into the
* form required by the <tt>Thread.join</tt> method.
*
* @param thread the thread to wait for
* @param timeout the maximum time to wait. If less than
* or equal to zero, do not wait at all.
* @throws InterruptedException if interrupted while waiting.
* @see Thread#join(long, int)
* @throws InterruptedException if interrupted while waiting
*/
public
void
timedJoin
(
Thread
thread
,
long
timeout
)
throws
InterruptedException
{
...
...
@@ -341,13 +344,14 @@ public enum TimeUnit {
}
/**
* Performs a <tt>Thread.sleep</tt> using this unit.
* Performs a {@link Thread#sleep(long, int) Thread.sleep} using
* this time unit.
* This is a convenience method that converts time arguments into the
* form required by the <tt>Thread.sleep</tt> method.
*
* @param timeout the minimum time to sleep. If less than
* or equal to zero, do not sleep at all.
* @throws InterruptedException if interrupted while sleeping.
* @see Thread#sleep
* @throws InterruptedException if interrupted while sleeping
*/
public
void
sleep
(
long
timeout
)
throws
InterruptedException
{
if
(
timeout
>
0
)
{
...
...
src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
浏览文件 @
3459dfdc
...
...
@@ -279,7 +279,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
sun
.
reflect
.
misc
.
ReflectUtil
.
ensureMemberAccess
(
caller
,
tclass
,
null
,
modifiers
);
sun
.
reflect
.
misc
.
ReflectUtil
.
checkPackageAccess
(
tclass
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
...
...
src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
浏览文件 @
3459dfdc
...
...
@@ -278,7 +278,7 @@ public abstract class AtomicLongFieldUpdater<T> {
sun
.
reflect
.
misc
.
ReflectUtil
.
ensureMemberAccess
(
caller
,
tclass
,
null
,
modifiers
);
sun
.
reflect
.
misc
.
ReflectUtil
.
checkPackageAccess
(
tclass
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
...
...
@@ -331,7 +331,7 @@ public abstract class AtomicLongFieldUpdater<T> {
if
(
cclass
.
isInstance
(
obj
))
{
return
;
}
throw
new
RuntimeException
(
throw
new
RuntimeException
(
new
IllegalAccessException
(
"Class "
+
cclass
.
getName
()
+
" can not access a protected member of class "
+
...
...
@@ -361,7 +361,7 @@ public abstract class AtomicLongFieldUpdater<T> {
sun
.
reflect
.
misc
.
ReflectUtil
.
ensureMemberAccess
(
caller
,
tclass
,
null
,
modifiers
);
sun
.
reflect
.
misc
.
ReflectUtil
.
checkPackageAccess
(
tclass
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
...
...
@@ -387,7 +387,7 @@ public abstract class AtomicLongFieldUpdater<T> {
public
boolean
compareAndSet
(
T
obj
,
long
expect
,
long
update
)
{
if
(
obj
==
null
||
obj
.
getClass
()
!=
tclass
||
cclass
!=
null
)
fullCheck
(
obj
);
synchronized
(
this
)
{
synchronized
(
this
)
{
long
v
=
unsafe
.
getLong
(
obj
,
offset
);
if
(
v
!=
expect
)
return
false
;
...
...
@@ -402,7 +402,7 @@ public abstract class AtomicLongFieldUpdater<T> {
public
void
set
(
T
obj
,
long
newValue
)
{
if
(
obj
==
null
||
obj
.
getClass
()
!=
tclass
||
cclass
!=
null
)
fullCheck
(
obj
);
synchronized
(
this
)
{
synchronized
(
this
)
{
unsafe
.
putLong
(
obj
,
offset
,
newValue
);
}
}
...
...
@@ -413,7 +413,7 @@ public abstract class AtomicLongFieldUpdater<T> {
public
long
get
(
T
obj
)
{
if
(
obj
==
null
||
obj
.
getClass
()
!=
tclass
||
cclass
!=
null
)
fullCheck
(
obj
);
synchronized
(
this
)
{
synchronized
(
this
)
{
return
unsafe
.
getLong
(
obj
,
offset
);
}
}
...
...
@@ -422,7 +422,7 @@ public abstract class AtomicLongFieldUpdater<T> {
if
(
cclass
.
isInstance
(
obj
))
{
return
;
}
throw
new
RuntimeException
(
throw
new
RuntimeException
(
new
IllegalAccessException
(
"Class "
+
cclass
.
getName
()
+
" can not access a protected member of class "
+
...
...
src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
浏览文件 @
3459dfdc
...
...
@@ -45,13 +45,13 @@ import java.lang.reflect.*;
* independently subject to atomic updates. For example, a tree node
* might be declared as
*
*
<pre>
*
<pre> {@code
* class Node {
* private volatile Node left, right;
*
* private static final AtomicReferenceFieldUpdater
<Node, Node>
leftUpdater =
* private static final AtomicReferenceFieldUpdater
<Node, Node>
leftUpdater =
* AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "left");
* private static AtomicReferenceFieldUpdater
<Node, Node>
rightUpdater =
* private static AtomicReferenceFieldUpdater
<Node, Node>
rightUpdater =
* AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
*
* Node getLeft() { return left; }
...
...
@@ -59,8 +59,7 @@ import java.lang.reflect.*;
* return leftUpdater.compareAndSet(this, expect, update);
* }
* // ... and so on
* }
* </pre>
* }}</pre>
*
* <p>Note that the guarantees of the {@code compareAndSet}
* method in this class are weaker than in other atomic classes.
...
...
@@ -291,7 +290,7 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
if
(
cclass
.
isInstance
(
obj
))
{
return
;
}
throw
new
RuntimeException
(
throw
new
RuntimeException
(
new
IllegalAccessException
(
"Class "
+
cclass
.
getName
()
+
" can not access a protected member of class "
+
...
...
src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
浏览文件 @
3459dfdc
...
...
@@ -990,7 +990,8 @@ public abstract class AbstractQueuedLongSynchronizer
* can represent anything you like.
* @throws InterruptedException if the current thread is interrupted
*/
public
final
void
acquireInterruptibly
(
long
arg
)
throws
InterruptedException
{
public
final
void
acquireInterruptibly
(
long
arg
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
if
(!
tryAcquire
(
arg
))
...
...
@@ -1014,7 +1015,8 @@ public abstract class AbstractQueuedLongSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public
final
boolean
tryAcquireNanos
(
long
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
public
final
boolean
tryAcquireNanos
(
long
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
return
tryAcquire
(
arg
)
||
...
...
@@ -1070,7 +1072,8 @@ public abstract class AbstractQueuedLongSynchronizer
* you like.
* @throws InterruptedException if the current thread is interrupted
*/
public
final
void
acquireSharedInterruptibly
(
long
arg
)
throws
InterruptedException
{
public
final
void
acquireSharedInterruptibly
(
long
arg
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
if
(
tryAcquireShared
(
arg
)
<
0
)
...
...
@@ -1093,7 +1096,8 @@ public abstract class AbstractQueuedLongSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public
final
boolean
tryAcquireSharedNanos
(
long
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
public
final
boolean
tryAcquireSharedNanos
(
long
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
return
tryAcquireShared
(
arg
)
>=
0
||
...
...
@@ -1841,7 +1845,8 @@ public abstract class AbstractQueuedLongSynchronizer
* <li> If interrupted while blocked in step 4, throw InterruptedException.
* </ol>
*/
public
final
long
awaitNanos
(
long
nanosTimeout
)
throws
InterruptedException
{
public
final
long
awaitNanos
(
long
nanosTimeout
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
Node
node
=
addConditionWaiter
();
...
...
@@ -1885,7 +1890,8 @@ public abstract class AbstractQueuedLongSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public
final
boolean
awaitUntil
(
Date
deadline
)
throws
InterruptedException
{
public
final
boolean
awaitUntil
(
Date
deadline
)
throws
InterruptedException
{
if
(
deadline
==
null
)
throw
new
NullPointerException
();
long
abstime
=
deadline
.
getTime
();
...
...
@@ -1928,7 +1934,8 @@ public abstract class AbstractQueuedLongSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public
final
boolean
await
(
long
time
,
TimeUnit
unit
)
throws
InterruptedException
{
public
final
boolean
await
(
long
time
,
TimeUnit
unit
)
throws
InterruptedException
{
if
(
unit
==
null
)
throw
new
NullPointerException
();
long
nanosTimeout
=
unit
.
toNanos
(
time
);
...
...
@@ -2084,7 +2091,7 @@ public abstract class AbstractQueuedLongSynchronizer
/**
* CAS waitStatus field of a node.
*/
private
final
static
boolean
compareAndSetWaitStatus
(
Node
node
,
private
static
final
boolean
compareAndSetWaitStatus
(
Node
node
,
int
expect
,
int
update
)
{
return
unsafe
.
compareAndSwapInt
(
node
,
waitStatusOffset
,
...
...
@@ -2094,7 +2101,7 @@ public abstract class AbstractQueuedLongSynchronizer
/**
* CAS next field of a node.
*/
private
final
static
boolean
compareAndSetNext
(
Node
node
,
private
static
final
boolean
compareAndSetNext
(
Node
node
,
Node
expect
,
Node
update
)
{
return
unsafe
.
compareAndSwapObject
(
node
,
nextOffset
,
expect
,
update
);
...
...
src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
浏览文件 @
3459dfdc
...
...
@@ -265,7 +265,7 @@ import sun.misc.Unsafe;
* boolean isSignalled() { return getState() != 0; }
*
* protected int tryAcquireShared(int ignore) {
* return isSignalled()? 1 : -1;
* return isSignalled()
? 1 : -1;
* }
*
* protected boolean tryReleaseShared(int ignore) {
...
...
@@ -1213,7 +1213,8 @@ public abstract class AbstractQueuedSynchronizer
* can represent anything you like.
* @throws InterruptedException if the current thread is interrupted
*/
public
final
void
acquireInterruptibly
(
int
arg
)
throws
InterruptedException
{
public
final
void
acquireInterruptibly
(
int
arg
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
if
(!
tryAcquire
(
arg
))
...
...
@@ -1237,7 +1238,8 @@ public abstract class AbstractQueuedSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public
final
boolean
tryAcquireNanos
(
int
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
public
final
boolean
tryAcquireNanos
(
int
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
return
tryAcquire
(
arg
)
||
...
...
@@ -1293,7 +1295,8 @@ public abstract class AbstractQueuedSynchronizer
* you like.
* @throws InterruptedException if the current thread is interrupted
*/
public
final
void
acquireSharedInterruptibly
(
int
arg
)
throws
InterruptedException
{
public
final
void
acquireSharedInterruptibly
(
int
arg
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
if
(
tryAcquireShared
(
arg
)
<
0
)
...
...
@@ -1316,7 +1319,8 @@ public abstract class AbstractQueuedSynchronizer
* @return {@code true} if acquired; {@code false} if timed out
* @throws InterruptedException if the current thread is interrupted
*/
public
final
boolean
tryAcquireSharedNanos
(
int
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
public
final
boolean
tryAcquireSharedNanos
(
int
arg
,
long
nanosTimeout
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
return
tryAcquireShared
(
arg
)
>=
0
||
...
...
@@ -2062,7 +2066,8 @@ public abstract class AbstractQueuedSynchronizer
* <li> If interrupted while blocked in step 4, throw InterruptedException.
* </ol>
*/
public
final
long
awaitNanos
(
long
nanosTimeout
)
throws
InterruptedException
{
public
final
long
awaitNanos
(
long
nanosTimeout
)
throws
InterruptedException
{
if
(
Thread
.
interrupted
())
throw
new
InterruptedException
();
Node
node
=
addConditionWaiter
();
...
...
@@ -2106,7 +2111,8 @@ public abstract class AbstractQueuedSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public
final
boolean
awaitUntil
(
Date
deadline
)
throws
InterruptedException
{
public
final
boolean
awaitUntil
(
Date
deadline
)
throws
InterruptedException
{
if
(
deadline
==
null
)
throw
new
NullPointerException
();
long
abstime
=
deadline
.
getTime
();
...
...
@@ -2149,7 +2155,8 @@ public abstract class AbstractQueuedSynchronizer
* <li> If timed out while blocked in step 4, return false, else true.
* </ol>
*/
public
final
boolean
await
(
long
time
,
TimeUnit
unit
)
throws
InterruptedException
{
public
final
boolean
await
(
long
time
,
TimeUnit
unit
)
throws
InterruptedException
{
if
(
unit
==
null
)
throw
new
NullPointerException
();
long
nanosTimeout
=
unit
.
toNanos
(
time
);
...
...
@@ -2305,7 +2312,7 @@ public abstract class AbstractQueuedSynchronizer
/**
* CAS waitStatus field of a node.
*/
private
final
static
boolean
compareAndSetWaitStatus
(
Node
node
,
private
static
final
boolean
compareAndSetWaitStatus
(
Node
node
,
int
expect
,
int
update
)
{
return
unsafe
.
compareAndSwapInt
(
node
,
waitStatusOffset
,
...
...
@@ -2315,7 +2322,7 @@ public abstract class AbstractQueuedSynchronizer
/**
* CAS next field of a node.
*/
private
final
static
boolean
compareAndSetNext
(
Node
node
,
private
static
final
boolean
compareAndSetNext
(
Node
node
,
Node
expect
,
Node
update
)
{
return
unsafe
.
compareAndSwapObject
(
node
,
nextOffset
,
expect
,
update
);
...
...
src/share/classes/java/util/concurrent/locks/LockSupport.java
浏览文件 @
3459dfdc
...
...
@@ -200,8 +200,8 @@ public class LockSupport {
* <li>Some other thread invokes {@link #unpark unpark} with the
* current thread as the target; or
*
* <li>Some other thread {@linkplain Thread#interrupt interrupts}
the current
* thread; or
* <li>Some other thread {@linkplain Thread#interrupt interrupts}
* th
e current th
read; or
*
* <li>The specified waiting time elapses; or
*
...
...
src/share/classes/java/util/concurrent/locks/ReentrantLock.java
浏览文件 @
3459dfdc
...
...
@@ -116,7 +116,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
* into fair and nonfair versions below. Uses AQS state to
* represent the number of holds on the lock.
*/
static
abstract
class
Sync
extends
AbstractQueuedSynchronizer
{
abstract
static
class
Sync
extends
AbstractQueuedSynchronizer
{
private
static
final
long
serialVersionUID
=
-
5179523762034025860L
;
/**
...
...
@@ -200,7 +200,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
/**
* Sync object for non-fair locks
*/
final
static
class
NonfairSync
extends
Sync
{
static
final
class
NonfairSync
extends
Sync
{
private
static
final
long
serialVersionUID
=
7316153563782823691L
;
/**
...
...
@@ -222,7 +222,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
/**
* Sync object for fair locks
*/
final
static
class
FairSync
extends
Sync
{
static
final
class
FairSync
extends
Sync
{
private
static
final
long
serialVersionUID
=
-
3000897897090466540L
;
final
void
lock
()
{
...
...
@@ -269,7 +269,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
* @param fair {@code true} if this lock should use a fair ordering policy
*/
public
ReentrantLock
(
boolean
fair
)
{
sync
=
(
fair
)
?
new
FairSync
()
:
new
NonfairSync
();
sync
=
fair
?
new
FairSync
()
:
new
NonfairSync
();
}
/**
...
...
@@ -440,7 +440,8 @@ public class ReentrantLock implements Lock, java.io.Serializable {
* @throws NullPointerException if the time unit is null
*
*/
public
boolean
tryLock
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
public
boolean
tryLock
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
return
sync
.
tryAcquireNanos
(
1
,
unit
.
toNanos
(
timeout
));
}
...
...
src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
浏览文件 @
3459dfdc
...
...
@@ -215,7 +215,8 @@ import java.util.*;
* @author Doug Lea
*
*/
public
class
ReentrantReadWriteLock
implements
ReadWriteLock
,
java
.
io
.
Serializable
{
public
class
ReentrantReadWriteLock
implements
ReadWriteLock
,
java
.
io
.
Serializable
{
private
static
final
long
serialVersionUID
=
-
6992448646407690164L
;
/** Inner class providing readlock */
private
final
ReentrantReadWriteLock
.
ReadLock
readerLock
;
...
...
@@ -251,7 +252,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
* Synchronization implementation for ReentrantReadWriteLock.
* Subclassed into fair and nonfair versions.
*/
static
abstract
class
Sync
extends
AbstractQueuedSynchronizer
{
abstract
static
class
Sync
extends
AbstractQueuedSynchronizer
{
private
static
final
long
serialVersionUID
=
6317671515068378041L
;
/*
...
...
@@ -618,7 +619,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
final
Thread
getOwner
()
{
// Must read state before owner to ensure memory consistency
return
((
exclusiveCount
(
getState
())
==
0
)?
return
((
exclusiveCount
(
getState
())
==
0
)
?
null
:
getExclusiveOwnerThread
());
}
...
...
@@ -669,7 +670,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
/**
* Nonfair version of Sync
*/
final
static
class
NonfairSync
extends
Sync
{
static
final
class
NonfairSync
extends
Sync
{
private
static
final
long
serialVersionUID
=
-
8159625535654395037L
;
final
boolean
writerShouldBlock
()
{
return
false
;
// writers can always barge
...
...
@@ -689,7 +690,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
/**
* Fair version of Sync
*/
final
static
class
FairSync
extends
Sync
{
static
final
class
FairSync
extends
Sync
{
private
static
final
long
serialVersionUID
=
-
2274990926593161451L
;
final
boolean
writerShouldBlock
()
{
return
hasQueuedPredecessors
();
...
...
@@ -867,7 +868,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
* @throws NullPointerException if the time unit is null
*
*/
public
boolean
tryLock
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
public
boolean
tryLock
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
return
sync
.
tryAcquireSharedNanos
(
1
,
unit
.
toNanos
(
timeout
));
}
...
...
@@ -1108,7 +1110,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab
* @throws NullPointerException if the time unit is null
*
*/
public
boolean
tryLock
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
public
boolean
tryLock
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
{
return
sync
.
tryAcquireNanos
(
1
,
unit
.
toNanos
(
timeout
));
}
...
...
test/java/util/concurrent/BlockingQueue/Interrupt.java
浏览文件 @
3459dfdc
...
...
@@ -136,5 +136,5 @@ public class Interrupt {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
private
abstract
static
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
}
test/java/util/concurrent/BlockingQueue/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -79,9 +79,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -79,9 +79,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/ConcurrentHashMap/MapCheck.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile MapCheck.java
* @compile
-source 1.5
MapCheck.java
* @run main/timeout=240 MapCheck
* @summary Times and checks basic map operations
*/
...
...
@@ -64,7 +64,7 @@ public class MapCheck {
if
(
args
.
length
>
0
)
{
try
{
mapClass
=
Class
.
forName
(
args
[
0
]);
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
throw
new
RuntimeException
(
"Class "
+
args
[
0
]
+
" not found."
);
}
}
...
...
@@ -102,7 +102,7 @@ public class MapCheck {
try
{
Map
m
=
(
Map
)
cl
.
newInstance
();
return
m
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Can't instantiate "
+
cl
+
": "
+
e
);
}
}
...
...
@@ -139,7 +139,7 @@ public class MapCheck {
}
}
timer
.
finish
();
reallyAssert
(
sum
==
expect
*
iters
);
reallyAssert
(
sum
==
expect
*
iters
);
}
static
void
t2
(
String
nm
,
int
n
,
Map
s
,
Object
[]
key
,
int
expect
)
{
...
...
@@ -149,7 +149,7 @@ public class MapCheck {
if
(
s
.
remove
(
key
[
i
])
!=
null
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
expect
);
reallyAssert
(
sum
==
expect
);
}
static
void
t3
(
String
nm
,
int
n
,
Map
s
,
Object
[]
key
,
int
expect
)
{
...
...
@@ -159,7 +159,7 @@ public class MapCheck {
if
(
s
.
put
(
key
[
i
],
absent
[
i
&
absentMask
])
==
null
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
expect
);
reallyAssert
(
sum
==
expect
);
}
static
void
t4
(
String
nm
,
int
n
,
Map
s
,
Object
[]
key
,
int
expect
)
{
...
...
@@ -169,7 +169,7 @@ public class MapCheck {
if
(
s
.
containsKey
(
key
[
i
]))
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
expect
);
reallyAssert
(
sum
==
expect
);
}
static
void
t5
(
String
nm
,
int
n
,
Map
s
,
Object
[]
key
,
int
expect
)
{
...
...
@@ -179,7 +179,7 @@ public class MapCheck {
if
(
s
.
remove
(
key
[
i
])
!=
null
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
expect
);
reallyAssert
(
sum
==
expect
);
}
static
void
t6
(
String
nm
,
int
n
,
Map
s
,
Object
[]
k1
,
Object
[]
k2
)
{
...
...
@@ -190,7 +190,7 @@ public class MapCheck {
if
(
s
.
get
(
k2
[
i
&
absentMask
])
!=
null
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
n
);
reallyAssert
(
sum
==
n
);
}
static
void
t7
(
String
nm
,
int
n
,
Map
s
,
Object
[]
k1
,
Object
[]
k2
)
{
...
...
@@ -201,7 +201,7 @@ public class MapCheck {
if
(
s
.
containsKey
(
k2
[
i
&
absentMask
]))
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
n
);
reallyAssert
(
sum
==
n
);
}
static
void
t8
(
String
nm
,
int
n
,
Map
s
,
Object
[]
key
,
int
expect
)
{
...
...
@@ -211,7 +211,7 @@ public class MapCheck {
if
(
s
.
get
(
key
[
i
])
!=
null
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
expect
);
reallyAssert
(
sum
==
expect
);
}
...
...
@@ -223,7 +223,7 @@ public class MapCheck {
for
(
int
i
=
0
;
i
<
absentSize
;
i
+=
step
)
if
(
s
.
containsValue
(
absent
[
i
]))
++
sum
;
timer
.
finish
();
reallyAssert
(
sum
!=
0
);
reallyAssert
(
sum
!=
0
);
}
...
...
@@ -235,7 +235,7 @@ public class MapCheck {
if
(
ks
.
contains
(
key
[
i
]))
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
...
...
@@ -243,37 +243,37 @@ public class MapCheck {
int
sum
=
0
;
timer
.
start
(
"Iter Key "
,
size
);
for
(
Iterator
it
=
s
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
if
(
it
.
next
()
!=
MISSING
)
if
(
it
.
next
()
!=
MISSING
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
static
void
ittest2
(
Map
s
,
int
size
)
{
int
sum
=
0
;
timer
.
start
(
"Iter Value "
,
size
);
for
(
Iterator
it
=
s
.
values
().
iterator
();
it
.
hasNext
();
)
{
if
(
it
.
next
()
!=
MISSING
)
if
(
it
.
next
()
!=
MISSING
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
static
void
ittest3
(
Map
s
,
int
size
)
{
int
sum
=
0
;
timer
.
start
(
"Iter Entry "
,
size
);
for
(
Iterator
it
=
s
.
entrySet
().
iterator
();
it
.
hasNext
();
)
{
if
(
it
.
next
()
!=
MISSING
)
if
(
it
.
next
()
!=
MISSING
)
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
static
void
ittest4
(
Map
s
,
int
size
,
int
pos
)
{
IdentityHashMap
seen
=
new
IdentityHashMap
(
size
);
reallyAssert
(
s
.
size
()
==
size
);
reallyAssert
(
s
.
size
()
==
size
);
int
sum
=
0
;
timer
.
start
(
"Iter XEntry "
,
size
);
Iterator
it
=
s
.
entrySet
().
iterator
();
...
...
@@ -287,9 +287,9 @@ public class MapCheck {
if
(
x
!=
MISSING
)
++
sum
;
}
reallyAssert
(
s
.
containsKey
(
k
));
reallyAssert
(
s
.
containsKey
(
k
));
it
.
remove
();
reallyAssert
(!
s
.
containsKey
(
k
));
reallyAssert
(!
s
.
containsKey
(
k
));
while
(
it
.
hasNext
())
{
Map
.
Entry
x
=
(
Map
.
Entry
)(
it
.
next
());
Object
k2
=
x
.
getKey
();
...
...
@@ -298,12 +298,12 @@ public class MapCheck {
++
sum
;
}
reallyAssert
(
s
.
size
()
==
size
-
1
);
reallyAssert
(
s
.
size
()
==
size
-
1
);
s
.
put
(
k
,
v
);
reallyAssert
(
seen
.
size
()
==
size
);
reallyAssert
(
seen
.
size
()
==
size
);
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
s
.
size
()
==
size
);
reallyAssert
(
sum
==
size
);
reallyAssert
(
s
.
size
()
==
size
);
}
...
...
@@ -324,7 +324,7 @@ public class MapCheck {
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
static
void
entest2
(
Hashtable
ht
,
int
size
)
{
...
...
@@ -335,7 +335,7 @@ public class MapCheck {
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
...
...
@@ -349,7 +349,7 @@ public class MapCheck {
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
static
void
entest4
(
Hashtable
ht
,
int
size
)
{
...
...
@@ -361,7 +361,7 @@ public class MapCheck {
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
}
static
void
entest
(
Map
s
,
int
size
)
{
...
...
@@ -409,13 +409,13 @@ public class MapCheck {
timer
.
start
(
"Iter Equals "
,
size
*
2
);
boolean
eqt
=
s2
.
equals
(
s
)
&&
s
.
equals
(
s2
);
reallyAssert
(
eqt
);
reallyAssert
(
eqt
);
timer
.
finish
();
timer
.
start
(
"Iter HashCode "
,
size
*
2
);
int
shc
=
s
.
hashCode
();
int
s2hc
=
s2
.
hashCode
();
reallyAssert
(
shc
==
s2hc
);
reallyAssert
(
shc
==
s2hc
);
timer
.
finish
();
timer
.
start
(
"Put (present) "
,
size
);
...
...
@@ -430,7 +430,7 @@ public class MapCheck {
if
(
es2
.
contains
(
entry
))
++
sum
;
}
timer
.
finish
();
reallyAssert
(
sum
==
size
);
reallyAssert
(
sum
==
size
);
t6
(
"Get "
,
size
,
s2
,
key
,
absent
);
...
...
@@ -438,13 +438,13 @@ public class MapCheck {
s2
.
put
(
key
[
size
-
1
],
absent
[
0
]);
timer
.
start
(
"Iter Equals "
,
size
*
2
);
eqt
=
s2
.
equals
(
s
)
&&
s
.
equals
(
s2
);
reallyAssert
(!
eqt
);
reallyAssert
(!
eqt
);
timer
.
finish
();
timer
.
start
(
"Iter HashCode "
,
size
*
2
);
int
s1h
=
s
.
hashCode
();
int
s2h
=
s2
.
hashCode
();
reallyAssert
(
s1h
!=
s2h
);
reallyAssert
(
s1h
!=
s2h
);
timer
.
finish
();
s2
.
put
(
key
[
size
-
1
],
hold
);
...
...
@@ -455,12 +455,12 @@ public class MapCheck {
es
.
remove
(
s2i
.
next
());
timer
.
finish
();
reallyAssert
(
s
.
isEmpty
());
reallyAssert
(
s
.
isEmpty
());
timer
.
start
(
"Clear "
,
size
);
s2
.
clear
();
timer
.
finish
();
reallyAssert
(
s2
.
isEmpty
()
&&
s
.
isEmpty
());
reallyAssert
(
s2
.
isEmpty
()
&&
s
.
isEmpty
());
}
static
void
stest
(
Map
s
,
int
size
)
throws
Exception
{
...
...
@@ -489,7 +489,7 @@ public class MapCheck {
System
.
out
.
print
(
time
+
"ms"
);
if
(
s
instanceof
IdentityHashMap
)
return
;
reallyAssert
(
s
.
equals
(
m
));
reallyAssert
(
s
.
equals
(
m
));
}
...
...
test/java/util/concurrent/ConcurrentHashMap/MapLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile MapLoops.java
* @compile
-source 1.5
MapLoops.java
* @run main/timeout=1600 MapLoops
* @summary Exercise multithreaded maps, by default ConcurrentHashMap.
* Multithreaded hash table test. Each thread does a random walk
...
...
@@ -225,7 +225,7 @@ public class MapLoops {
barrier
.
await
();
}
catch
(
Throwable
throwable
)
{
synchronized
(
System
.
err
)
{
synchronized
(
System
.
err
)
{
System
.
err
.
println
(
"--------------------------------"
);
throwable
.
printStackTrace
();
}
...
...
test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -79,9 +79,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java
浏览文件 @
3459dfdc
...
...
@@ -66,7 +66,7 @@ public class EqualsRace {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
CheckedThread
extends
Thread
{
private
abstract
static
class
CheckedThread
extends
Thread
{
public
abstract
void
realRun
()
throws
Throwable
;
public
void
run
()
{
try
{
realRun
();
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}}}
...
...
test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java
浏览文件 @
3459dfdc
...
...
@@ -125,7 +125,7 @@ public class RacingCows {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
CheckedThread
extends
Thread
{
private
abstract
static
class
CheckedThread
extends
Thread
{
public
abstract
void
realRun
()
throws
Throwable
;
public
void
run
()
{
try
{
realRun
();
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}}}
...
...
test/java/util/concurrent/CyclicBarrier/Basic.java
浏览文件 @
3459dfdc
...
...
@@ -83,7 +83,7 @@ public class Basic {
//----------------------------------------------------------------
// Convenience methods for creating threads that call CyclicBarrier.await
//----------------------------------------------------------------
private
static
abstract
class
Awaiter
extends
Thread
{
private
abstract
static
class
Awaiter
extends
Thread
{
static
AtomicInteger
count
=
new
AtomicInteger
(
1
);
{
...
...
@@ -417,14 +417,14 @@ public class Basic {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
static
abstract
class
Fun
{
abstract
void
f
()
throws
Throwable
;
}
abstract
static
class
Fun
{
abstract
void
f
()
throws
Throwable
;
}
private
static
void
THROWS
(
Class
<?
extends
Throwable
>
k
,
Fun
...
fs
)
{
for
(
Fun
f
:
fs
)
try
{
f
.
f
();
fail
(
"Expected "
+
k
.
getName
()
+
" not thrown"
);
}
catch
(
Throwable
t
)
{
if
(
k
.
isAssignableFrom
(
t
.
getClass
()))
pass
();
else
unexpected
(
t
);}}
private
static
abstract
class
CheckedThread
extends
Thread
{
private
abstract
static
class
CheckedThread
extends
Thread
{
abstract
void
realRun
()
throws
Throwable
;
public
void
run
()
{
try
{
realRun
();}
catch
(
Throwable
t
)
{
unexpected
(
t
);}}}
...
...
test/java/util/concurrent/Exchanger/ExchangeLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile ExchangeLoops.java
* @compile
-source 1.5
ExchangeLoops.java
* @run main/timeout=720 ExchangeLoops
* @summary checks to make sure a pipeline of exchangers passes data.
*/
...
...
@@ -78,7 +78,7 @@ public class ExchangeLoops {
final
Exchanger
<
Int
>
right
;
final
CyclicBarrier
barrier
;
volatile
int
result
;
Stage
(
Exchanger
<
Int
>
left
,
Stage
(
Exchanger
<
Int
>
left
,
Exchanger
<
Int
>
right
,
CyclicBarrier
b
,
int
iters
)
{
this
.
left
=
left
;
...
...
test/java/util/concurrent/Exchanger/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -78,9 +78,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4965960
* @compile ExecutorCompletionServiceLoops.java
* @compile
-source 1.5
ExecutorCompletionServiceLoops.java
* @run main/timeout=3600 ExecutorCompletionServiceLoops
* @summary Exercise ExecutorCompletionServiceLoops
*/
...
...
test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -78,9 +78,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/Executors/Throws.java
浏览文件 @
3459dfdc
...
...
@@ -122,7 +122,7 @@ public class Throws {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
private
abstract
static
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
static
void
THROWS
(
Class
<?
extends
Throwable
>
k
,
Fun
...
fs
)
{
for
(
Fun
f
:
fs
)
try
{
f
.
f
();
fail
(
"Expected "
+
k
.
getName
()
+
" not thrown"
);
}
...
...
test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java
浏览文件 @
3459dfdc
...
...
@@ -87,7 +87,7 @@ public class BlockingTaskExecutor {
* A helper class with a method to wait for a notification.
*
* The notification is received via the
*
<code>sendNotification</code>
method.
*
{@code sendNotification}
method.
*/
static
class
NotificationReceiver
{
/** Has the notifiee been notified? */
...
...
test/java/util/concurrent/FutureTask/CancelledFutureLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile CancelledFutureLoops.java
* @compile
-source 1.5
CancelledFutureLoops.java
* @run main/timeout=2000 CancelledFutureLoops
* @summary Checks for responsiveness of futures to cancellation.
* Runs under the assumption that ITERS computations require more than
...
...
@@ -64,10 +64,10 @@ public final class CancelledFutureLoops {
try
{
new
FutureLoop
(
i
).
test
();
}
catch
(
BrokenBarrierException
bb
)
{
catch
(
BrokenBarrierException
bb
)
{
// OK; ignore
}
catch
(
ExecutionException
ee
)
{
catch
(
ExecutionException
ee
)
{
// OK; ignore
}
Thread
.
sleep
(
TIMEOUT
);
...
...
test/java/util/concurrent/FutureTask/Customized.java
浏览文件 @
3459dfdc
...
...
@@ -203,7 +203,7 @@ public class Customized {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
private
abstract
static
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
static
void
THROWS
(
Class
<?
extends
Throwable
>
k
,
Fun
...
fs
)
{
for
(
Fun
f
:
fs
)
try
{
f
.
f
();
fail
(
"Expected "
+
k
.
getName
()
+
" not thrown"
);
}
...
...
test/java/util/concurrent/FutureTask/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -78,9 +78,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java
浏览文件 @
3459dfdc
...
...
@@ -161,11 +161,8 @@ public class DelayOverflow {
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
pass
();
else
fail
(
x
+
" not equal to "
+
y
);}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
Class
<?>
k
=
new
Object
(){}.
getClass
().
getEnclosingClass
();
try
{
k
.
getMethod
(
"instanceMain"
,
String
[].
class
)
.
invoke
(
k
.
newInstance
(),
(
Object
)
args
);}
catch
(
Throwable
e
)
{
throw
e
.
getCause
();}}
public
void
instanceMain
(
String
[]
args
)
throws
Throwable
{
new
DelayOverflow
().
instanceMain
(
args
);}
void
instanceMain
(
String
[]
args
)
throws
Throwable
{
try
{
test
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
...
...
test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
浏览文件 @
3459dfdc
...
...
@@ -36,9 +36,9 @@ import java.util.concurrent.atomic.*;
import
static
java
.
util
.
concurrent
.
TimeUnit
.*;
public
class
ConfigChanges
{
final
static
ThreadGroup
tg
=
new
ThreadGroup
(
"pool"
);
static
final
ThreadGroup
tg
=
new
ThreadGroup
(
"pool"
);
final
static
Random
rnd
=
new
Random
();
static
final
Random
rnd
=
new
Random
();
static
void
report
(
ThreadPoolExecutor
tpe
)
{
try
{
...
...
@@ -241,7 +241,7 @@ public class ConfigChanges {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
private
abstract
static
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
static
void
THROWS
(
Class
<?
extends
Throwable
>
k
,
Fun
...
fs
)
{
for
(
Fun
f
:
fs
)
try
{
f
.
f
();
fail
(
"Expected "
+
k
.
getName
()
+
" not thrown"
);
}
...
...
test/java/util/concurrent/ThreadPoolExecutor/Custom.java
浏览文件 @
3459dfdc
...
...
@@ -43,7 +43,7 @@ public class Custom {
private
static
class
CustomTask
<
V
>
extends
FutureTask
<
V
>
{
public
final
static
AtomicInteger
births
=
new
AtomicInteger
(
0
);
public
static
final
AtomicInteger
births
=
new
AtomicInteger
(
0
);
CustomTask
(
Callable
<
V
>
c
)
{
super
(
c
);
births
.
getAndIncrement
();
}
CustomTask
(
Runnable
r
,
V
v
)
{
super
(
r
,
v
);
births
.
getAndIncrement
();
}
}
...
...
@@ -63,7 +63,7 @@ public class Custom {
}
private
static
class
CustomSTPE
extends
ScheduledThreadPoolExecutor
{
public
final
static
AtomicInteger
decorations
=
new
AtomicInteger
(
0
);
public
static
final
AtomicInteger
decorations
=
new
AtomicInteger
(
0
);
CustomSTPE
()
{
super
(
threadCount
);
}
...
...
@@ -89,7 +89,7 @@ public class Custom {
return
count
;
}
private
final
static
int
threadCount
=
10
;
private
static
final
int
threadCount
=
10
;
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
CustomTPE
tpe
=
new
CustomTPE
();
...
...
test/java/util/concurrent/ThreadPoolExecutor/ScheduledTickleService.java
浏览文件 @
3459dfdc
...
...
@@ -37,10 +37,10 @@ public class ScheduledTickleService {
// We get intermittent ClassCastException if greater than 1
// because of calls to compareTo
private
final
static
int
concurrency
=
2
;
private
static
final
int
concurrency
=
2
;
// Record when tasks are done
public
final
static
CountDownLatch
done
=
new
CountDownLatch
(
concurrency
);
public
static
final
CountDownLatch
done
=
new
CountDownLatch
(
concurrency
);
public
static
void
realMain
(
String
...
args
)
throws
InterruptedException
{
// our tickle service
...
...
test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java
浏览文件 @
3459dfdc
...
...
@@ -40,7 +40,7 @@ public class ShutdownNowExecuteRace {
static
volatile
boolean
quit
=
false
;
static
volatile
ThreadPoolExecutor
pool
=
null
;
final
static
Runnable
sleeper
=
new
Runnable
()
{
public
void
run
()
{
static
final
Runnable
sleeper
=
new
Runnable
()
{
public
void
run
()
{
final
long
ONE_HOUR
=
1000L
*
60L
*
60L
;
try
{
Thread
.
sleep
(
ONE_HOUR
);
}
catch
(
InterruptedException
ie
)
{}
...
...
@@ -81,14 +81,14 @@ public class ShutdownNowExecuteRace {
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
private
static
abstract
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
private
abstract
static
class
Fun
{
abstract
void
f
()
throws
Throwable
;}
static
void
THROWS
(
Class
<?
extends
Throwable
>
k
,
Fun
...
fs
)
{
for
(
Fun
f
:
fs
)
try
{
f
.
f
();
fail
(
"Expected "
+
k
.
getName
()
+
" not thrown"
);
}
catch
(
Throwable
t
)
{
if
(
k
.
isAssignableFrom
(
t
.
getClass
()))
pass
();
else
unexpected
(
t
);}}
private
static
abstract
class
CheckedThread
extends
Thread
{
private
abstract
static
class
CheckedThread
extends
Thread
{
abstract
void
realRun
()
throws
Throwable
;
public
void
run
()
{
try
{
realRun
();}
catch
(
Throwable
t
)
{
unexpected
(
t
);}}}
...
...
test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
浏览文件 @
3459dfdc
...
...
@@ -35,7 +35,7 @@ import java.util.concurrent.*;
import
java.util.concurrent.atomic.*
;
public
class
ThrowingTasks
{
final
static
Random
rnd
=
new
Random
();
static
final
Random
rnd
=
new
Random
();
@SuppressWarnings
(
"serial"
)
static
class
UncaughtExceptions
...
...
@@ -65,16 +65,16 @@ public class ThrowingTasks {
}
}
final
static
UncaughtExceptions
uncaughtExceptions
static
final
UncaughtExceptions
uncaughtExceptions
=
new
UncaughtExceptions
();
final
static
UncaughtExceptionsTable
uncaughtExceptionsTable
static
final
UncaughtExceptionsTable
uncaughtExceptionsTable
=
new
UncaughtExceptionsTable
();
final
static
AtomicLong
totalUncaughtExceptions
static
final
AtomicLong
totalUncaughtExceptions
=
new
AtomicLong
(
0
);
final
static
CountDownLatch
uncaughtExceptionsLatch
static
final
CountDownLatch
uncaughtExceptionsLatch
=
new
CountDownLatch
(
24
);
final
static
Thread
.
UncaughtExceptionHandler
handler
static
final
Thread
.
UncaughtExceptionHandler
handler
=
new
Thread
.
UncaughtExceptionHandler
()
{
public
void
uncaughtException
(
Thread
t
,
Throwable
e
)
{
check
(!
Thread
.
currentThread
().
isInterrupted
());
...
...
@@ -84,19 +84,19 @@ public class ThrowingTasks {
uncaughtExceptionsLatch
.
countDown
();
}};
final
static
ThreadGroup
tg
=
new
ThreadGroup
(
"Flaky"
);
static
final
ThreadGroup
tg
=
new
ThreadGroup
(
"Flaky"
);
final
static
ThreadFactory
tf
=
new
ThreadFactory
()
{
static
final
ThreadFactory
tf
=
new
ThreadFactory
()
{
public
Thread
newThread
(
Runnable
r
)
{
Thread
t
=
new
Thread
(
tg
,
r
);
t
.
setUncaughtExceptionHandler
(
handler
);
return
t
;
}};
final
static
RuntimeException
rte
=
new
RuntimeException
();
final
static
Error
error
=
new
Error
();
final
static
Throwable
weird
=
new
Throwable
();
final
static
Exception
checkedException
=
new
Exception
();
static
final
RuntimeException
rte
=
new
RuntimeException
();
static
final
Error
error
=
new
Error
();
static
final
Throwable
weird
=
new
Throwable
();
static
final
Exception
checkedException
=
new
Exception
();
static
class
Thrower
implements
Runnable
{
Throwable
t
;
...
...
@@ -105,13 +105,13 @@ public class ThrowingTasks {
public
void
run
()
{
if
(
t
!=
null
)
Thread
.
currentThread
().
stop
(
t
);
}
}
final
static
Thrower
noThrower
=
new
Thrower
(
null
);
final
static
Thrower
rteThrower
=
new
Thrower
(
rte
);
final
static
Thrower
errorThrower
=
new
Thrower
(
error
);
final
static
Thrower
weirdThrower
=
new
Thrower
(
weird
);
final
static
Thrower
checkedThrower
=
new
Thrower
(
checkedException
);
static
final
Thrower
noThrower
=
new
Thrower
(
null
);
static
final
Thrower
rteThrower
=
new
Thrower
(
rte
);
static
final
Thrower
errorThrower
=
new
Thrower
(
error
);
static
final
Thrower
weirdThrower
=
new
Thrower
(
weird
);
static
final
Thrower
checkedThrower
=
new
Thrower
(
checkedException
);
final
static
List
<
Thrower
>
throwers
=
Arrays
.
asList
(
static
final
List
<
Thrower
>
throwers
=
Arrays
.
asList
(
noThrower
,
rteThrower
,
errorThrower
,
weirdThrower
,
checkedThrower
);
static
class
Flaky
implements
Runnable
{
...
...
test/java/util/concurrent/atomic/VMSupportsCS8.java
浏览文件 @
3459dfdc
...
...
@@ -24,6 +24,8 @@
/*
* @test
* @bug 4992443 4994819
* @compile -source 1.5 VMSupportsCS8.java
* @run main VMSupportsCS8
* @summary Checks that the value of VMSupportsCS8 matches system properties.
*/
...
...
test/java/util/concurrent/locks/Lock/FlakyMutex.java
浏览文件 @
3459dfdc
...
...
@@ -75,10 +75,10 @@ public class FlakyMutex implements Lock {
catch
(
Throwable
t
)
{
checkThrowable
(
t
);
}
}
try
{
check
(!
m
.
tryLock
());
}
try
{
check
(!
m
.
tryLock
());
}
catch
(
Throwable
t
)
{
checkThrowable
(
t
);
}
try
{
check
(!
m
.
tryLock
(
1
,
TimeUnit
.
MICROSECONDS
));
}
try
{
check
(!
m
.
tryLock
(
1
,
TimeUnit
.
MICROSECONDS
));
}
catch
(
Throwable
t
)
{
checkThrowable
(
t
);
}
m
.
unlock
();
...
...
test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java
浏览文件 @
3459dfdc
...
...
@@ -64,7 +64,7 @@ public class TimedAcquireLeak {
return
outputOf
(
new
InputStreamReader
(
is
,
"UTF-8"
));
}
final
static
ExecutorService
drainers
=
Executors
.
newFixedThreadPool
(
12
);
static
final
ExecutorService
drainers
=
Executors
.
newFixedThreadPool
(
12
);
static
Future
<
String
>
futureOutputOf
(
final
InputStream
is
)
{
return
drainers
.
submit
(
new
Callable
<
String
>()
{
public
String
call
()
throws
IOException
{
...
...
test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile CancelledLockLoops.java
* @compile
-source 1.5
CancelledLockLoops.java
* @run main/timeout=2800 CancelledLockLoops
* @summary tests lockInterruptibly.
* Checks for responsiveness of locks to interrupts. Runs under that
...
...
@@ -64,7 +64,7 @@ public final class CancelledLockLoops {
try
{
new
ReentrantLockLoop
(
i
).
test
();
}
catch
(
BrokenBarrierException
bb
)
{
catch
(
BrokenBarrierException
bb
)
{
// OK, ignore
}
Thread
.
sleep
(
TIMEOUT
);
...
...
test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile LockOncePerThreadLoops.java
* @compile
-source 1.5
LockOncePerThreadLoops.java
* @run main/timeout=15000 LockOncePerThreadLoops
* @summary Checks for missed signals by locking and unlocking each of an array of locks once per thread
*/
...
...
test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -78,9 +78,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile SimpleReentrantLockLoops.java
* @compile
-source 1.5
SimpleReentrantLockLoops.java
* @run main/timeout=4500 SimpleReentrantLockLoops
* @summary multiple threads using a single lock
*/
...
...
test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,6 +34,8 @@
/*
* @test
* @bug 4486658 5031862
* @compile -source 1.5 TimeoutLockLoops.java
* @run main TimeoutLockLoops
* @summary Checks for responsiveness of locks to timeouts.
* Runs under the assumption that ITERS computations require more than
* TIMEOUT msecs to complete, which seems to be a safe assumption for
...
...
test/java/util/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java
浏览文件 @
3459dfdc
...
...
@@ -45,7 +45,7 @@ public class Bug6571733 {
Thread
thread
=
new
Thread
()
{
public
void
run
()
{
try
{
check
(!
lock
.
writeLock
().
tryLock
(
0
,
TimeUnit
.
DAYS
));
check
(!
lock
.
writeLock
().
tryLock
(
0
,
TimeUnit
.
DAYS
));
lock
.
readLock
().
lock
();
lock
.
readLock
().
unlock
();
...
...
test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java
浏览文件 @
3459dfdc
...
...
@@ -78,9 +78,9 @@ class LoopHelpers {
* Basically same as java.util.Random.
*/
public
static
class
SimpleRandom
{
private
final
static
long
multiplier
=
0x5DEECE66D
L
;
private
final
static
long
addend
=
0xB
L
;
private
final
static
long
mask
=
(
1L
<<
48
)
-
1
;
private
static
final
long
multiplier
=
0x5DEECE66D
L
;
private
static
final
long
addend
=
0xB
L
;
private
static
final
long
mask
=
(
1L
<<
48
)
-
1
;
static
final
AtomicLong
seq
=
new
AtomicLong
(
1
);
private
long
seed
=
System
.
nanoTime
()
+
seq
.
getAndIncrement
();
...
...
test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java
浏览文件 @
3459dfdc
...
...
@@ -34,7 +34,7 @@
/*
* @test
* @bug 4486658
* @compile MapLoops.java
* @compile
-source 1.5
MapLoops.java
* @run main/timeout=4700 MapLoops
* @summary Exercise multithreaded maps, by default ConcurrentHashMap.
* Multithreaded hash table test. Each thread does a random walk
...
...
@@ -65,7 +65,7 @@ public class MapLoops {
if
(
args
.
length
>
0
)
{
try
{
mapClass
=
Class
.
forName
(
args
[
0
]);
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
throw
new
RuntimeException
(
"Class "
+
args
[
0
]
+
" not found."
);
}
}
...
...
test/java/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java
浏览文件 @
3459dfdc
...
...
@@ -57,21 +57,33 @@ public class RWMap implements Map {
}
public
int
size
()
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
size
();}
finally
{
rwl
.
readLock
().
unlock
();
}
rwl
.
readLock
().
lock
();
try
{
return
m
.
size
();
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
boolean
isEmpty
(){
rwl
.
readLock
().
lock
();
try
{
return
m
.
isEmpty
();}
finally
{
rwl
.
readLock
().
unlock
();
}
public
boolean
isEmpty
()
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
isEmpty
();
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
Object
get
(
Object
key
)
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
get
(
key
);}
finally
{
rwl
.
readLock
().
unlock
();
}
rwl
.
readLock
().
lock
();
try
{
return
m
.
get
(
key
);
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
boolean
containsKey
(
Object
key
)
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
containsKey
(
key
);}
finally
{
rwl
.
readLock
().
unlock
();
}
rwl
.
readLock
().
lock
();
try
{
return
m
.
containsKey
(
key
);
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
boolean
containsValue
(
Object
value
){
rwl
.
readLock
().
lock
();
try
{
return
m
.
containsValue
(
value
);}
finally
{
rwl
.
readLock
().
unlock
();
}
public
boolean
containsValue
(
Object
value
)
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
containsValue
(
value
);
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
...
...
@@ -88,28 +100,45 @@ public class RWMap implements Map {
}
public
boolean
equals
(
Object
o
)
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
equals
(
o
);}
finally
{
rwl
.
readLock
().
unlock
();
}
rwl
.
readLock
().
lock
();
try
{
return
m
.
equals
(
o
);
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
int
hashCode
()
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
hashCode
();}
finally
{
rwl
.
readLock
().
unlock
();
}
rwl
.
readLock
().
lock
();
try
{
return
m
.
hashCode
();
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
String
toString
()
{
rwl
.
readLock
().
lock
();
try
{
return
m
.
toString
();}
finally
{
rwl
.
readLock
().
unlock
();
}
rwl
.
readLock
().
lock
();
try
{
return
m
.
toString
();
}
finally
{
rwl
.
readLock
().
unlock
();
}
}
public
Object
put
(
Object
key
,
Object
value
)
{
rwl
.
writeLock
().
lock
();
try
{
return
m
.
put
(
key
,
value
);}
finally
{
rwl
.
writeLock
().
unlock
();
}
rwl
.
writeLock
().
lock
();
try
{
return
m
.
put
(
key
,
value
);
}
finally
{
rwl
.
writeLock
().
unlock
();
}
}
public
Object
remove
(
Object
key
)
{
rwl
.
writeLock
().
lock
();
try
{
return
m
.
remove
(
key
);}
finally
{
rwl
.
writeLock
().
unlock
();
}
rwl
.
writeLock
().
lock
();
try
{
return
m
.
remove
(
key
);
}
finally
{
rwl
.
writeLock
().
unlock
();
}
}
public
void
putAll
(
Map
map
)
{
rwl
.
writeLock
().
lock
();
try
{
m
.
putAll
(
map
);}
finally
{
rwl
.
writeLock
().
unlock
();
}
rwl
.
writeLock
().
lock
();
try
{
m
.
putAll
(
map
);
}
finally
{
rwl
.
writeLock
().
unlock
();
}
}
public
void
clear
()
{
rwl
.
writeLock
().
lock
();
try
{
m
.
clear
();}
finally
{
rwl
.
writeLock
().
unlock
();
}
rwl
.
writeLock
().
lock
();
try
{
m
.
clear
();
}
finally
{
rwl
.
writeLock
().
unlock
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录