Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e22c5084
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看板
提交
e22c5084
编写于
2月 16, 2011
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6562203: Thread doesn't terminate immediately if it was stopped before start
Reviewed-by: dholmes, alanb
上级
41631e4b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
167 deletion
+9
-167
src/share/classes/java/lang/Thread.java
src/share/classes/java/lang/Thread.java
+9
-35
test/java/lang/Thread/StopBeforeStart.java
test/java/lang/Thread/StopBeforeStart.java
+0
-132
未找到文件。
src/share/classes/java/lang/Thread.java
浏览文件 @
e22c5084
...
@@ -254,12 +254,6 @@ class Thread implements Runnable {
...
@@ -254,12 +254,6 @@ class Thread implements Runnable {
*/
*/
public
final
static
int
MAX_PRIORITY
=
10
;
public
final
static
int
MAX_PRIORITY
=
10
;
/* If stop was called before start */
private
boolean
stopBeforeStart
;
/* Remembered Throwable from stop before start */
private
Throwable
throwableFromStop
;
/**
/**
* Returns a reference to the currently executing thread object.
* Returns a reference to the currently executing thread object.
*
*
...
@@ -706,10 +700,6 @@ class Thread implements Runnable {
...
@@ -706,10 +700,6 @@ class Thread implements Runnable {
it will be passed up the call stack */
it will be passed up the call stack */
}
}
}
}
if
(
stopBeforeStart
)
{
stop0
(
throwableFromStop
);
}
}
}
private
native
void
start0
();
private
native
void
start0
();
...
@@ -820,12 +810,7 @@ class Thread implements Runnable {
...
@@ -820,12 +810,7 @@ class Thread implements Runnable {
*/
*/
@Deprecated
@Deprecated
public
final
void
stop
()
{
public
final
void
stop
()
{
// If the thread is already dead, return.
stop
(
new
ThreadDeath
());
// A zero status value corresponds to "NEW".
if
((
threadStatus
!=
0
)
&&
!
isAlive
())
{
return
;
}
stop1
(
new
ThreadDeath
());
}
}
/**
/**
...
@@ -879,36 +864,25 @@ class Thread implements Runnable {
...
@@ -879,36 +864,25 @@ class Thread implements Runnable {
*/
*/
@Deprecated
@Deprecated
public
final
synchronized
void
stop
(
Throwable
obj
)
{
public
final
synchronized
void
stop
(
Throwable
obj
)
{
stop1
(
obj
);
if
(
obj
==
null
)
}
throw
new
NullPointerException
();
/**
* Common impl for stop() and stop(Throwable).
*/
private
final
synchronized
void
stop1
(
Throwable
th
)
{
SecurityManager
security
=
System
.
getSecurityManager
();
SecurityManager
security
=
System
.
getSecurityManager
();
if
(
security
!=
null
)
{
if
(
security
!=
null
)
{
checkAccess
();
checkAccess
();
if
((
this
!=
Thread
.
currentThread
())
||
if
((
this
!=
Thread
.
currentThread
())
||
(!(
th
instanceof
ThreadDeath
)))
{
(!(
obj
instanceof
ThreadDeath
)))
{
security
.
checkPermission
(
SecurityConstants
.
STOP_THREAD_PERMISSION
);
security
.
checkPermission
(
SecurityConstants
.
STOP_THREAD_PERMISSION
);
}
}
}
}
// A zero status value corresponds to "NEW"
// A zero status value corresponds to "NEW", it can't change to
// not-NEW because we hold the lock.
if
(
threadStatus
!=
0
)
{
if
(
threadStatus
!=
0
)
{
resume
();
// Wake up thread if it was suspended; no-op otherwise
resume
();
// Wake up thread if it was suspended; no-op otherwise
stop0
(
th
);
}
else
{
// Must do the null arg check that the VM would do with stop0
if
(
th
==
null
)
{
throw
new
NullPointerException
();
}
// Remember this stop attempt for if/when start is used
stopBeforeStart
=
true
;
throwableFromStop
=
th
;
}
}
// The VM can handle all thread states
stop0
(
obj
);
}
}
/**
/**
...
...
test/java/lang/Thread/StopBeforeStart.java
已删除
100644 → 0
浏览文件 @
41631e4b
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4519200
* @summary Confirm a Thread.stop before start complies with the spec
* @author Pete Soper
*
* Confirm that a thread that had its stop method invoked before start
* does properly terminate with expected exception behavior. NOTE that
* arbitrary application threads could return from their run methods faster
* than the VM can throw an async exception.
*/
public
class
StopBeforeStart
{
private
static
final
int
JOIN_TIMEOUT
=
10000
;
private
class
MyThrowable
extends
Throwable
{
}
private
class
Catcher
implements
Thread
.
UncaughtExceptionHandler
{
private
boolean
nullaryStop
;
private
Throwable
theThrowable
;
private
Throwable
expectedThrowable
;
private
boolean
exceptionThrown
;
Catcher
(
boolean
nullaryStop
)
{
this
.
nullaryStop
=
nullaryStop
;
if
(!
nullaryStop
)
{
expectedThrowable
=
new
MyThrowable
();
}
}
public
void
uncaughtException
(
Thread
t
,
Throwable
th
)
{
exceptionThrown
=
true
;
theThrowable
=
th
;
}
void
check
(
String
label
)
throws
Throwable
{
if
(!
exceptionThrown
)
{
throw
new
RuntimeException
(
label
+
" test:"
+
" missing uncaught exception"
);
}
if
(
nullaryStop
)
{
if
(!
(
theThrowable
instanceof
ThreadDeath
))
{
throw
new
RuntimeException
(
label
+
" test:"
+
" expected ThreadDeath in uncaught handler"
);
}
}
else
if
(
theThrowable
!=
expectedThrowable
)
{
throw
new
RuntimeException
(
label
+
" test:"
+
" wrong Throwable in uncaught handler"
);
}
}
}
private
class
MyRunnable
implements
Runnable
{
public
void
run
()
{
while
(
true
)
;
}
}
private
class
MyThread
extends
Thread
{
public
void
run
()
{
while
(
true
)
;
}
}
public
static
void
main
(
String
args
[])
throws
Throwable
{
(
new
StopBeforeStart
()).
doit
();
System
.
out
.
println
(
"Test passed"
);
}
private
void
doit
()
throws
Throwable
{
runit
(
false
,
new
Thread
(
new
MyRunnable
()),
"Thread"
);
runit
(
true
,
new
Thread
(
new
MyRunnable
()),
"Thread"
);
runit
(
false
,
new
MyThread
(),
"Runnable"
);
runit
(
true
,
new
MyThread
(),
"Runnable"
);
}
private
void
runit
(
boolean
nullaryStop
,
Thread
thread
,
String
type
)
throws
Throwable
{
Catcher
c
=
new
Catcher
(
nullaryStop
);
thread
.
setUncaughtExceptionHandler
(
c
);
if
(
nullaryStop
)
{
thread
.
stop
();
}
else
{
thread
.
stop
(
c
.
expectedThrowable
);
}
thread
.
start
();
thread
.
join
(
JOIN_TIMEOUT
);
if
(
thread
.
getState
()
!=
Thread
.
State
.
TERMINATED
)
{
thread
.
stop
();
// Under high load this could be a false positive
throw
new
RuntimeException
(
type
+
" test:"
+
" app thread did not terminate"
);
}
c
.
check
(
type
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录