Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
74b0748e
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看板
提交
74b0748e
编写于
3月 10, 2008
作者:
M
martin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6633113: test/java/util/concurrent/SynchronousQueue/Fairness.java fails intermittently
Reviewed-by: dholmes
上级
f112b5be
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
16 deletion
+29
-16
test/java/util/concurrent/SynchronousQueue/Fairness.java
test/java/util/concurrent/SynchronousQueue/Fairness.java
+29
-16
未找到文件。
test/java/util/concurrent/SynchronousQueue/Fairness.java
浏览文件 @
74b0748e
...
@@ -23,36 +23,49 @@
...
@@ -23,36 +23,49 @@
/*
/*
* @test
* @test
* @bug 4992438
* @bug 4992438 6633113
* @compile -source 1.5 Fairness.java
* @run main Fairness
* @summary Checks that fairness setting is respected.
* @summary Checks that fairness setting is respected.
*/
*/
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
import
java.util.concurrent.locks.*
;
public
class
Fairness
{
public
class
Fairness
{
private
static
void
testFairness
(
boolean
fair
,
private
static
void
testFairness
(
boolean
fair
,
final
BlockingQueue
<
Integer
>
q
)
final
BlockingQueue
<
Integer
>
q
)
throws
Exception
throws
Throwable
{
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
final
ReentrantLock
lock
=
new
ReentrantLock
();
final
Integer
I
=
new
Integer
(
i
);
final
Condition
ready
=
lock
.
newCondition
();
new
Thread
()
{
public
void
run
()
{
final
int
threadCount
=
10
;
try
{
q
.
put
(
I
);
}
catch
(
Exception
e
)
{}
final
Throwable
[]
badness
=
new
Throwable
[
1
];
}}.
start
();
lock
.
lock
();
Thread
.
currentThread
().
sleep
(
100
);
for
(
int
i
=
0
;
i
<
threadCount
;
i
++)
{
final
Integer
I
=
i
;
Thread
t
=
new
Thread
()
{
public
void
run
()
{
try
{
lock
.
lock
();
ready
.
signal
();
lock
.
unlock
();
q
.
put
(
I
);
}
catch
(
Throwable
t
)
{
badness
[
0
]
=
t
;
}}};
t
.
start
();
ready
.
await
();
// Probably unnecessary, but should be bullet-proof
while
(
t
.
getState
()
==
Thread
.
State
.
RUNNABLE
)
Thread
.
yield
();
}
}
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
threadCount
;
i
++)
{
int
j
=
q
.
take
().
intValue
();
int
j
=
q
.
take
();
System
.
err
.
printf
(
"%d%n"
,
j
);
// Non-fair queues are lifo in our implementation
// Non-fair queues are lifo in our implementation
if
(
fair
?
j
!=
i
:
j
!=
2
-
i
)
if
(
fair
?
j
!=
i
:
j
!=
threadCount
-
1
-
i
)
throw
new
Exception
(
"No fair!"
);
throw
new
Error
(
String
.
format
(
"fair=%b i=%d j=%d%n"
,
fair
,
i
,
j
));
}
}
if
(
badness
[
0
]
!=
null
)
throw
new
Error
(
badness
[
0
]);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
testFairness
(
false
,
new
SynchronousQueue
<
Integer
>());
testFairness
(
false
,
new
SynchronousQueue
<
Integer
>());
testFairness
(
false
,
new
SynchronousQueue
<
Integer
>(
false
));
testFairness
(
false
,
new
SynchronousQueue
<
Integer
>(
false
));
testFairness
(
true
,
new
SynchronousQueue
<
Integer
>(
true
));
testFairness
(
true
,
new
SynchronousQueue
<
Integer
>(
true
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录