Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
96f5c8b9
提交
96f5c8b9
authored
10月 03, 2018
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
concurrent tests little refactoring
上级
7e2ec608
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
32 行删除
+43
-32
TestConcurrentUpdate.java
h2/src/test/org/h2/test/synth/TestConcurrentUpdate.java
+9
-10
TestMultiThreaded.java
h2/src/test/org/h2/test/synth/TestMultiThreaded.java
+34
-22
没有找到文件。
h2/src/test/org/h2/test/synth/TestConcurrentUpdate.java
浏览文件 @
96f5c8b9
...
@@ -100,18 +100,17 @@ public class TestConcurrentUpdate extends TestDb {
...
@@ -100,18 +100,17 @@ public class TestConcurrentUpdate extends TestDb {
t
.
execute
();
t
.
execute
();
}
}
// test 2 seconds
// test 2 seconds
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
Thread
.
sleep
(
2000
);
Thread
.
sleep
(
10
);
boolean
success
=
true
;
for
(
Task
t
:
tasks
)
{
if
(
t
.
isFinished
())
{
i
=
1000
;
break
;
}
}
}
for
(
Task
t
:
tasks
)
{
for
(
Task
t
:
tasks
)
{
t
.
get
();
t
.
join
();
Throwable
exception
=
t
.
getException
();
if
(
exception
!=
null
)
{
logError
(
""
,
exception
);
success
=
false
;
}
}
}
assert
success
;
}
}
}
}
}
}
h2/src/test/org/h2/test/synth/TestMultiThreaded.java
浏览文件 @
96f5c8b9
...
@@ -25,7 +25,17 @@ public class TestMultiThreaded extends TestDb {
...
@@ -25,7 +25,17 @@ public class TestMultiThreaded extends TestDb {
* @param a ignored
* @param a ignored
*/
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
org
.
h2
.
test
.
TestAll
config
=
new
org
.
h2
.
test
.
TestAll
();
config
.
memory
=
true
;
config
.
big
=
true
;
System
.
out
.
println
(
config
);
TestBase
test
=
createCaller
().
init
(
config
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
System
.
out
.
println
(
"Pass #"
+
i
);
test
.
config
.
beforeTest
();
test
.
test
();
test
.
config
.
afterTest
();
}
}
}
/**
/**
...
@@ -128,8 +138,7 @@ public class TestMultiThreaded extends TestDb {
...
@@ -128,8 +138,7 @@ public class TestMultiThreaded extends TestDb {
int
size
=
getSize
(
2
,
4
);
int
size
=
getSize
(
2
,
4
);
Connection
[]
connList
=
new
Connection
[
size
];
Connection
[]
connList
=
new
Connection
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
connList
[
i
]
=
getConnection
(
"multiThreaded;MULTI_THREADED=1;"
+
connList
[
i
]
=
getConnection
(
"multiThreaded;MULTI_THREADED=1"
);
"TRACE_LEVEL_SYSTEM_OUT=1"
);
}
}
Connection
conn
=
connList
[
0
];
Connection
conn
=
connList
[
0
];
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -148,32 +157,35 @@ public class TestMultiThreaded extends TestDb {
...
@@ -148,32 +157,35 @@ public class TestMultiThreaded extends TestDb {
trace
(
"started "
+
i
);
trace
(
"started "
+
i
);
Thread
.
sleep
(
100
);
Thread
.
sleep
(
100
);
}
}
for
(
int
t
=
0
;
t
<
2
;
t
++)
{
try
{
Thread
.
sleep
(
1000
);
Thread
.
sleep
(
2000
);
}
finally
{
trace
(
"stopping"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Processor
p
=
processors
[
i
];
Processor
p
=
processors
[
i
];
if
(
p
.
getException
()
!=
null
)
{
p
.
stopNow
();
throw
new
Exception
(
""
+
i
,
p
.
getException
());
}
}
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Processor
p
=
processors
[
i
];
p
.
join
(
1000
);
}
trace
(
"close"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
connList
[
i
].
close
();
}
deleteDb
(
"multiThreaded"
);
}
}
trace
(
"stopping"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
boolean
success
=
true
;
Processor
p
=
processors
[
i
];
p
.
stopNow
();
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Processor
p
=
processors
[
i
];
Processor
p
=
processors
[
i
];
p
.
join
(
100
);
p
.
join
(
10000
);
if
(
p
.
getException
()
!=
null
)
{
Throwable
exception
=
p
.
getException
();
throw
new
Exception
(
p
.
getException
());
if
(
exception
!=
null
)
{
logError
(
""
,
exception
);
success
=
false
;
}
}
}
}
trace
(
"close"
);
assert
success
;
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
connList
[
i
].
close
();
}
deleteDb
(
"multiThreaded"
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论