Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
e532d028
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e532d028
编写于
3月 03, 2017
作者:
D
dl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8173909: Miscellaneous changes imported from jsr166 CVS 2017-03
Reviewed-by: martin, psandoz
上级
22d2412e
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
858 addition
and
808 deletion
+858
-808
jdk/src/java.base/share/classes/java/util/SplittableRandom.java
...c/java.base/share/classes/java/util/SplittableRandom.java
+1
-2
jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java
...hare/classes/java/util/concurrent/ArrayBlockingQueue.java
+1
-0
jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
...share/classes/java/util/concurrent/ThreadLocalRandom.java
+1
-2
jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
...es/java/util/concurrent/locks/ReentrantReadWriteLock.java
+2
-4
jdk/test/java/util/concurrent/ArrayBlockingQueue/IteratorConsistency.java
...il/concurrent/ArrayBlockingQueue/IteratorConsistency.java
+0
-755
jdk/test/java/util/concurrent/ArrayBlockingQueue/WhiteBox.java
...est/java/util/concurrent/ArrayBlockingQueue/WhiteBox.java
+759
-0
jdk/test/java/util/concurrent/tck/JSR166TestCase.java
jdk/test/java/util/concurrent/tck/JSR166TestCase.java
+43
-3
jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
...est/java/util/concurrent/tck/LinkedTransferQueueTest.java
+13
-7
jdk/test/java/util/concurrent/tck/PhaserTest.java
jdk/test/java/util/concurrent/tck/PhaserTest.java
+10
-10
jdk/test/java/util/concurrent/tck/StampedLockTest.java
jdk/test/java/util/concurrent/tck/StampedLockTest.java
+28
-25
未找到文件。
jdk/src/java.base/share/classes/java/util/SplittableRandom.java
浏览文件 @
e532d028
...
...
@@ -779,8 +779,7 @@ public final class SplittableRandom {
* @return a stream of pseudorandom {@code double} values,
* each with the given origin (inclusive) and bound (exclusive)
* @throws IllegalArgumentException if {@code streamSize} is
* less than zero
* @throws IllegalArgumentException if {@code randomNumberOrigin}
* less than zero, or {@code randomNumberOrigin}
* is greater than or equal to {@code randomNumberBound}
*/
public
DoubleStream
doubles
(
long
streamSize
,
double
randomNumberOrigin
,
...
...
jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java
浏览文件 @
e532d028
...
...
@@ -1226,6 +1226,7 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
}
else
{
nextIndex
=
NONE
;
nextItem
=
null
;
if
(
lastRet
==
REMOVED
)
detach
();
}
}
finally
{
lock
.
unlock
();
...
...
jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
浏览文件 @
e532d028
...
...
@@ -699,8 +699,7 @@ public class ThreadLocalRandom extends Random {
* @return a stream of pseudorandom {@code double} values,
* each with the given origin (inclusive) and bound (exclusive)
* @throws IllegalArgumentException if {@code streamSize} is
* less than zero
* @throws IllegalArgumentException if {@code randomNumberOrigin}
* less than zero, or {@code randomNumberOrigin}
* is greater than or equal to {@code randomNumberBound}
* @since 1.8
*/
...
...
jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
浏览文件 @
e532d028
...
...
@@ -53,16 +53,14 @@ import jdk.internal.vm.annotation.ReservedStackAccess;
*
* <dl>
* <dt><b><i>Non-fair mode (default)</i></b>
* <dd style="font-family:'DejaVu Sans', Arial, Helvetica, sans-serif">
* When constructed as non-fair (the default), the order of entry
* <dd>When constructed as non-fair (the default), the order of entry
* to the read and write lock is unspecified, subject to reentrancy
* constraints. A nonfair lock that is continuously contended may
* indefinitely postpone one or more reader or writer threads, but
* will normally have higher throughput than a fair lock.
*
* <dt><b><i>Fair mode</i></b>
* <dd style="font-family:'DejaVu Sans', Arial, Helvetica, sans-serif">
* When constructed as fair, threads contend for entry using an
* <dd>When constructed as fair, threads contend for entry using an
* approximately arrival-order policy. When the currently held lock
* is released, either the longest-waiting single writer thread will
* be assigned the write lock, or if there is a group of reader threads
...
...
jdk/test/java/util/concurrent/ArrayBlockingQueue/IteratorConsistency.java
已删除
100644 → 0
浏览文件 @
22d2412e
此差异已折叠。
点击以展开。
jdk/test/java/util/concurrent/ArrayBlockingQueue/WhiteBox.java
0 → 100644
浏览文件 @
e532d028
此差异已折叠。
点击以展开。
jdk/test/java/util/concurrent/tck/JSR166TestCase.java
浏览文件 @
e532d028
...
...
@@ -1326,20 +1326,60 @@ public class JSR166TestCase extends TestCase {
startTime
=
System
.
nanoTime
();
else
if
(
millisElapsedSince
(
startTime
)
>
timeoutMillis
)
{
threadAssertTrue
(
thread
.
isAlive
());
return
;
fail
(
"timed out waiting for thread to enter wait state"
);
}
Thread
.
yield
();
}
}
/**
* Spin-waits up to the specified number of milliseconds for the given
* thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING,
* and additionally satisfy the given condition.
*/
void
waitForThreadToEnterWaitState
(
Thread
thread
,
long
timeoutMillis
,
Callable
<
Boolean
>
waitingForGodot
)
{
long
startTime
=
0L
;
for
(;;)
{
Thread
.
State
s
=
thread
.
getState
();
if
(
s
==
Thread
.
State
.
BLOCKED
||
s
==
Thread
.
State
.
WAITING
||
s
==
Thread
.
State
.
TIMED_WAITING
)
{
try
{
if
(
waitingForGodot
.
call
())
return
;
}
catch
(
Throwable
fail
)
{
threadUnexpectedException
(
fail
);
}
}
else
if
(
s
==
Thread
.
State
.
TERMINATED
)
fail
(
"Unexpected thread termination"
);
else
if
(
startTime
==
0L
)
startTime
=
System
.
nanoTime
();
else
if
(
millisElapsedSince
(
startTime
)
>
timeoutMillis
)
{
threadAssertTrue
(
thread
.
isAlive
());
fail
(
"timed out waiting for thread to enter wait state"
);
}
Thread
.
yield
();
}
}
/**
*
Waits up to LONG_DELAY_MS for the given thread to enter a wait
* state: BLOCKED, WAITING, or TIMED_WAITING.
*
Spin-waits up to LONG_DELAY_MS milliseconds for the given thread to
*
enter a wait
state: BLOCKED, WAITING, or TIMED_WAITING.
*/
void
waitForThreadToEnterWaitState
(
Thread
thread
)
{
waitForThreadToEnterWaitState
(
thread
,
LONG_DELAY_MS
);
}
/**
* Spin-waits up to LONG_DELAY_MS milliseconds for the given thread to
* enter a wait state: BLOCKED, WAITING, or TIMED_WAITING,
* and additionally satisfy the given condition.
*/
void
waitForThreadToEnterWaitState
(
Thread
thread
,
Callable
<
Boolean
>
waitingForGodot
)
{
waitForThreadToEnterWaitState
(
thread
,
LONG_DELAY_MS
,
waitingForGodot
);
}
/**
* Returns the number of milliseconds since time given by
* startNanoTime, which must have been previously returned from a
...
...
jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
浏览文件 @
e532d028
...
...
@@ -42,6 +42,7 @@ import java.util.List;
import
java.util.NoSuchElementException
;
import
java.util.Queue
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ExecutorService
;
...
...
@@ -766,9 +767,11 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
}});
threadStarted
.
await
();
waitForThreadToEnterWaitState
(
t
);
assertEquals
(
1
,
q
.
getWaitingConsumerCount
());
assertTrue
(
q
.
hasWaitingConsumer
());
Callable
<
Boolean
>
oneConsumer
=
new
Callable
<
Boolean
>()
{
public
Boolean
call
()
{
return
q
.
hasWaitingConsumer
()
&&
q
.
getWaitingConsumerCount
()
==
1
;
}};
waitForThreadToEnterWaitState
(
t
,
oneConsumer
);
assertTrue
(
q
.
offer
(
one
));
assertEquals
(
0
,
q
.
getWaitingConsumerCount
());
...
...
@@ -790,7 +793,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
/**
* transfer waits until a poll occurs. The transfered element
* is returned by th
is
associated poll.
* is returned by th
e
associated poll.
*/
public
void
testTransfer2
()
throws
InterruptedException
{
final
LinkedTransferQueue
<
Integer
>
q
=
new
LinkedTransferQueue
<>();
...
...
@@ -804,8 +807,11 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
}});
threadStarted
.
await
();
waitForThreadToEnterWaitState
(
t
);
assertEquals
(
1
,
q
.
size
());
Callable
<
Boolean
>
oneElement
=
new
Callable
<
Boolean
>()
{
public
Boolean
call
()
{
return
!
q
.
isEmpty
()
&&
q
.
size
()
==
1
;
}};
waitForThreadToEnterWaitState
(
t
,
oneElement
);
assertSame
(
five
,
q
.
poll
());
checkEmpty
(
q
);
awaitTermination
(
t
);
...
...
@@ -868,7 +874,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
/**
* transfer waits until a take occurs. The transfered element
* is returned by th
is
associated take.
* is returned by th
e
associated take.
*/
public
void
testTransfer5
()
throws
InterruptedException
{
final
LinkedTransferQueue
<
Integer
>
q
=
new
LinkedTransferQueue
<>();
...
...
jdk/test/java/util/concurrent/tck/PhaserTest.java
浏览文件 @
e532d028
...
...
@@ -550,7 +550,7 @@ public class PhaserTest extends JSR166TestCase {
}});
await
(
pleaseArrive
);
waitForThreadToEnterWaitState
(
t
,
SHORT_DELAY_MS
);
waitForThreadToEnterWaitState
(
t
);
assertEquals
(
0
,
phaser
.
arrive
());
awaitTermination
(
t
);
...
...
@@ -578,7 +578,7 @@ public class PhaserTest extends JSR166TestCase {
}});
await
(
pleaseArrive
);
waitForThreadToEnterWaitState
(
t
,
SHORT_DELAY_MS
);
waitForThreadToEnterWaitState
(
t
);
t
.
interrupt
();
assertEquals
(
0
,
phaser
.
arrive
());
awaitTermination
(
t
);
...
...
@@ -594,20 +594,20 @@ public class PhaserTest extends JSR166TestCase {
public
void
testArriveAndAwaitAdvanceAfterInterrupt
()
{
final
Phaser
phaser
=
new
Phaser
();
assertEquals
(
0
,
phaser
.
register
());
final
CountDownLatch
please
Interrupt
=
new
CountDownLatch
(
1
);
final
CountDownLatch
please
Arrive
=
new
CountDownLatch
(
1
);
Thread
t
=
newStartedThread
(
new
CheckedRunnable
()
{
public
void
realRun
()
{
Thread
.
currentThread
().
interrupt
();
assertEquals
(
0
,
phaser
.
register
());
please
Interrupt
.
countDown
();
please
Arrive
.
countDown
();
assertTrue
(
Thread
.
currentThread
().
isInterrupted
());
assertEquals
(
1
,
phaser
.
arriveAndAwaitAdvance
());
assertTrue
(
Thread
.
currentThread
().
isI
nterrupted
());
assertTrue
(
Thread
.
i
nterrupted
());
}});
await
(
please
Interrupt
);
waitForThreadToEnterWaitState
(
t
,
SHORT_DELAY_MS
);
await
(
please
Arrive
);
waitForThreadToEnterWaitState
(
t
);
Thread
.
currentThread
().
interrupt
();
assertEquals
(
1
,
phaser
.
arriveAndAwaitAdvance
());
assertTrue
(
Thread
.
interrupted
());
...
...
@@ -628,11 +628,11 @@ public class PhaserTest extends JSR166TestCase {
assertFalse
(
Thread
.
currentThread
().
isInterrupted
());
pleaseInterrupt
.
countDown
();
assertEquals
(
1
,
phaser
.
arriveAndAwaitAdvance
());
assertTrue
(
Thread
.
currentThread
().
isI
nterrupted
());
assertTrue
(
Thread
.
i
nterrupted
());
}});
await
(
pleaseInterrupt
);
waitForThreadToEnterWaitState
(
t
,
SHORT_DELAY_MS
);
waitForThreadToEnterWaitState
(
t
);
t
.
interrupt
();
Thread
.
currentThread
().
interrupt
();
assertEquals
(
1
,
phaser
.
arriveAndAwaitAdvance
());
...
...
@@ -807,7 +807,7 @@ public class PhaserTest extends JSR166TestCase {
assertEquals
(
THREADS
,
phaser
.
getArrivedParties
());
assertTrue
(
millisElapsedSince
(
startTime
)
<
LONG_DELAY_MS
);
for
(
Thread
thread
:
threads
)
waitForThreadToEnterWaitState
(
thread
,
SHORT_DELAY_MS
);
waitForThreadToEnterWaitState
(
thread
);
for
(
Thread
thread
:
threads
)
assertTrue
(
thread
.
isAlive
());
assertState
(
phaser
,
0
,
THREADS
+
1
,
1
);
...
...
jdk/test/java/util/concurrent/tck/StampedLockTest.java
浏览文件 @
e532d028
...
...
@@ -299,7 +299,6 @@ public class StampedLockTest extends JSR166TestCase {
* interruptible operations throw InterruptedException when pre-interrupted
*/
public
void
testInterruptibleOperationsThrowInterruptedExceptionWhenPreInterrupted
()
{
final
CountDownLatch
running
=
new
CountDownLatch
(
1
);
final
StampedLock
lock
=
new
StampedLock
();
Action
[]
interruptibleLockActions
=
{
...
...
@@ -364,7 +363,6 @@ public class StampedLockTest extends JSR166TestCase {
* interruptible operations throw InterruptedException when write locked and interrupted
*/
public
void
testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInterrupted
()
{
final
CountDownLatch
running
=
new
CountDownLatch
(
1
);
final
StampedLock
lock
=
new
StampedLock
();
long
s
=
lock
.
writeLock
();
...
...
@@ -387,7 +385,6 @@ public class StampedLockTest extends JSR166TestCase {
* interruptible operations throw InterruptedException when read locked and interrupted
*/
public
void
testInterruptibleOperationsThrowInterruptedExceptionReadLockedInterrupted
()
{
final
CountDownLatch
running
=
new
CountDownLatch
(
1
);
final
StampedLock
lock
=
new
StampedLock
();
long
s
=
lock
.
readLock
();
...
...
@@ -506,29 +503,32 @@ public class StampedLockTest extends JSR166TestCase {
}
/**
*
A writelock
succeeds only after a reading thread unlocks
*
writeLock()
succeeds only after a reading thread unlocks
*/
public
void
testWriteAfterReadLock
()
throws
InterruptedException
{
final
CountDownLatch
running
=
new
CountDownLatch
(
1
);
final
CountDownLatch
aboutToLock
=
new
CountDownLatch
(
1
);
final
StampedLock
lock
=
new
StampedLock
();
long
rs
=
lock
.
readLock
();
Thread
t
=
newStartedThread
(
new
CheckedRunnable
()
{
public
void
realRun
()
{
running
.
countDown
();
aboutToLock
.
countDown
();
long
s
=
lock
.
writeLock
();
assertTrue
(
lock
.
isWriteLocked
());
assertFalse
(
lock
.
isReadLocked
());
lock
.
unlockWrite
(
s
);
}});
running
.
await
();
waitForThreadToEnterWaitState
(
t
,
MEDIUM_DELAY_MS
);
aboutToLock
.
await
();
waitForThreadToEnterWaitState
(
t
);
assertFalse
(
lock
.
isWriteLocked
());
assertTrue
(
lock
.
isReadLocked
());
lock
.
unlockRead
(
rs
);
awaitTermination
(
t
);
assert
False
(
lock
.
isWriteLocked
()
);
assert
Unlocked
(
lock
);
}
/**
*
A writelock
succeeds only after reading threads unlock
*
writeLock()
succeeds only after reading threads unlock
*/
public
void
testWriteAfterMultipleReadLocks
()
{
final
StampedLock
lock
=
new
StampedLock
();
...
...
@@ -551,35 +551,36 @@ public class StampedLockTest extends JSR166TestCase {
assertFalse
(
lock
.
isWriteLocked
());
lock
.
unlockRead
(
s
);
awaitTermination
(
t2
);
assert
False
(
lock
.
isWriteLocked
()
);
assert
Unlocked
(
lock
);
}
/**
*
Readlocks
succeed only after a writing thread unlocks
*
readLock()
succeed only after a writing thread unlocks
*/
public
void
testReadAfterWriteLock
()
{
final
StampedLock
lock
=
new
StampedLock
();
final
CountDownLatch
threadsStarted
=
new
CountDownLatch
(
2
);
final
long
s
=
lock
.
writeLock
();
Thread
t1
=
newStartedThread
(
new
CheckedRunnable
()
{
public
void
realRun
()
{
threadsStarted
.
countDown
();
long
rs
=
lock
.
readLock
();
lock
.
unlockRead
(
rs
);
}});
Thread
t2
=
newStartedThread
(
new
CheckedRunnable
()
{
final
Runnable
acquireReleaseReadLock
=
new
CheckedRunnable
()
{
public
void
realRun
()
{
threadsStarted
.
countDown
();
long
rs
=
lock
.
readLock
();
assertTrue
(
lock
.
isReadLocked
());
assertFalse
(
lock
.
isWriteLocked
());
lock
.
unlockRead
(
rs
);
}});
}};
Thread
t1
=
newStartedThread
(
acquireReleaseReadLock
);
Thread
t2
=
newStartedThread
(
acquireReleaseReadLock
);
await
(
threadsStarted
);
waitForThreadToEnterWaitState
(
t1
,
MEDIUM_DELAY_MS
);
waitForThreadToEnterWaitState
(
t2
,
MEDIUM_DELAY_MS
);
waitForThreadToEnterWaitState
(
t1
);
waitForThreadToEnterWaitState
(
t2
);
assertTrue
(
lock
.
isWriteLocked
());
assertFalse
(
lock
.
isReadLocked
());
releaseWriteLock
(
lock
,
s
);
awaitTermination
(
t1
);
awaitTermination
(
t2
);
assertUnlocked
(
lock
);
}
/**
...
...
@@ -765,22 +766,24 @@ public class StampedLockTest extends JSR166TestCase {
*/
public
void
testValidateOptimisticWriteLocked2
()
throws
InterruptedException
{
final
CountDownLatch
running
=
new
CountDownLatch
(
1
);
final
CountDownLatch
locked
=
new
CountDownLatch
(
1
);
final
StampedLock
lock
=
new
StampedLock
();
final
long
p
=
assertValid
(
lock
,
lock
.
tryOptimisticRead
());
Thread
t
=
newStartedThread
(
new
CheckedInterruptedRunnable
()
{
public
void
realRun
()
throws
InterruptedException
{
lock
.
writeLockInterruptibly
();
running
.
countDown
();
locked
.
countDown
();
lock
.
writeLockInterruptibly
();
}});
running
.
await
();
locked
.
await
();
assertFalse
(
lock
.
validate
(
p
));
assertEquals
(
0L
,
lock
.
tryOptimisticRead
());
waitForThreadToEnterWaitState
(
t
);
t
.
interrupt
();
awaitTermination
(
t
);
assertTrue
(
lock
.
isWriteLocked
());
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录