Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
906a8055
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
906a8055
编写于
2月 12, 2016
作者:
J
jbachorik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8034168: ThreadMXBean/Locks.java failed, blocked on wrong object
Reviewed-by: martin, dholmes
上级
ac729b08
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
12 deletion
+29
-12
test/java/lang/management/ThreadMXBean/Locks.java
test/java/lang/management/ThreadMXBean/Locks.java
+29
-12
未找到文件。
test/java/lang/management/ThreadMXBean/Locks.java
浏览文件 @
906a8055
...
@@ -170,6 +170,9 @@ public class Locks {
...
@@ -170,6 +170,9 @@ public class Locks {
private
static
CheckerThread
checker
;
private
static
CheckerThread
checker
;
static
class
WaitingThread
extends
Thread
{
static
class
WaitingThread
extends
Thread
{
private
final
Phaser
p
;
private
final
Phaser
p
;
volatile
boolean
waiting
=
false
;
public
WaitingThread
(
Phaser
p
)
{
public
WaitingThread
(
Phaser
p
)
{
super
(
"WaitingThread"
);
super
(
"WaitingThread"
);
this
.
p
=
p
;
this
.
p
=
p
;
...
@@ -180,7 +183,9 @@ public class Locks {
...
@@ -180,7 +183,9 @@ public class Locks {
log
(
"WaitingThread about to wait on objC"
);
log
(
"WaitingThread about to wait on objC"
);
try
{
try
{
// Signal checker thread, about to wait on objC.
// Signal checker thread, about to wait on objC.
waiting
=
false
;
p
.
arriveAndAwaitAdvance
();
// Phase 1 (waiting)
p
.
arriveAndAwaitAdvance
();
// Phase 1 (waiting)
waiting
=
true
;
objC
.
wait
();
objC
.
wait
();
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -199,7 +204,9 @@ public class Locks {
...
@@ -199,7 +204,9 @@ public class Locks {
synchronized
(
objC
)
{
synchronized
(
objC
)
{
try
{
try
{
// signal checker thread, about to wait on objC
// signal checker thread, about to wait on objC
waiting
=
false
;
p
.
arriveAndAwaitAdvance
();
// Phase 3 (waiting)
p
.
arriveAndAwaitAdvance
();
// Phase 3 (waiting)
waiting
=
true
;
objC
.
wait
();
objC
.
wait
();
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -208,25 +215,35 @@ public class Locks {
...
@@ -208,25 +215,35 @@ public class Locks {
}
}
log
(
"WaitingThread about to exit waiting on objC 2"
);
log
(
"WaitingThread about to exit waiting on objC 2"
);
}
}
public
void
waitForWaiting
()
{
p
.
arriveAndAwaitAdvance
();
while
(!
waiting
)
{
goSleep
(
10
);
}
}
static
class
CheckerThread
extends
Thread
{
waitForState
(
State
.
WAITING
);
private
final
Phaser
p
;
public
CheckerThread
(
Phaser
p
)
{
super
(
"CheckerThread"
);
this
.
p
=
p
;
}
}
p
rivate
void
waitForState
(
Thread
.
State
state
)
{
p
ublic
void
waitForBlocked
(
)
{
p
.
arriveAndAwaitAdvance
();
p
.
arriveAndAwaitAdvance
();
waitForState
(
State
.
BLOCKED
);
}
private
void
waitForState
(
Thread
.
State
state
)
{
while
(!
waiter
.
isInterrupted
()
&&
waiter
.
getState
()
!=
state
)
{
while
(!
waiter
.
isInterrupted
()
&&
waiter
.
getState
()
!=
state
)
{
goSleep
(
10
);
Thread
.
yield
(
);
}
}
}
}
}
static
class
CheckerThread
extends
Thread
{
public
CheckerThread
()
{
super
(
"CheckerThread"
);
}
public
void
run
()
{
public
void
run
()
{
synchronized
(
ready
)
{
synchronized
(
ready
)
{
// wait until WaitingThread about to wait for objC
// wait until WaitingThread about to wait for objC
wait
ForState
(
Thread
.
State
.
WAITING
);
// Phase 1 (waiting)
wait
er
.
waitForWaiting
(
);
// Phase 1 (waiting)
checkBlockedObject
(
waiter
,
objC
,
null
,
Thread
.
State
.
WAITING
);
checkBlockedObject
(
waiter
,
objC
,
null
,
Thread
.
State
.
WAITING
);
synchronized
(
objC
)
{
synchronized
(
objC
)
{
...
@@ -235,13 +252,13 @@ public class Locks {
...
@@ -235,13 +252,13 @@ public class Locks {
// wait for waiter thread to about to enter
// wait for waiter thread to about to enter
// synchronized object ready.
// synchronized object ready.
wait
ForState
(
Thread
.
State
.
BLOCKED
);
// Phase 2 (waiting)
wait
er
.
waitForBlocked
(
);
// Phase 2 (waiting)
checkBlockedObject
(
waiter
,
ready
,
this
,
Thread
.
State
.
BLOCKED
);
checkBlockedObject
(
waiter
,
ready
,
this
,
Thread
.
State
.
BLOCKED
);
}
}
// wait for signal from waiting thread that it is about
// wait for signal from waiting thread that it is about
// wait for objC.
// wait for objC.
wait
ForState
(
Thread
.
State
.
WAITING
);
// Phase 3 (waiting)
wait
er
.
waitForWaiting
(
);
// Phase 3 (waiting)
synchronized
(
objC
)
{
synchronized
(
objC
)
{
checkBlockedObject
(
waiter
,
objC
,
Thread
.
currentThread
(),
Thread
.
State
.
WAITING
);
checkBlockedObject
(
waiter
,
objC
,
Thread
.
currentThread
(),
Thread
.
State
.
WAITING
);
objC
.
notify
();
objC
.
notify
();
...
@@ -289,7 +306,7 @@ public class Locks {
...
@@ -289,7 +306,7 @@ public class Locks {
waiter
=
new
WaitingThread
(
p
);
waiter
=
new
WaitingThread
(
p
);
waiter
.
start
();
waiter
.
start
();
checker
=
new
CheckerThread
(
p
);
checker
=
new
CheckerThread
();
checker
.
start
();
checker
.
start
();
try
{
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录