为什么、我继承了THREAD类后对应超类的STOP方法被加了删除线,不能用?

Alain_Delone 2002-11-28 07:14:05
我用JBUILDER7,自己写个类派生THREAD,可是我用直接在自己类里用超类的STOP方法
提示时候STOP加了删除线,这是什么意思
编译时候还会有以下的警告

"XChatServer.java": Warning #: 368 : method stop() in class java.lang.Thread has been deprecated at line 186, column 21

希望高手指点
...全文
62 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Alain_Delone 2002-11-28
  • 打赏
  • 举报
回复
没的具体了啊,和程序没关系,就是调用了超类(THREAD)的STOP方法就警告,既然帮助说不安全,那有别的什么方法终止一个线程
snowchicken 2002-11-28
  • 打赏
  • 举报
回复
能不能说具体点,或者把程序贴出来看看。
windofsun 2002-11-28
  • 打赏
  • 举报
回复
Why is Thread.stop deprecated?

Because it is inherently unsafe. Stopping a thread causes it to unlock all the monitors that it has locked. (The monitors are unlocked as the ThreadDeath exception propagates up the stack.) If any of the objects previously protected by these monitors were in an inconsistent state, other threads may now view these objects in an inconsistent state. Such objects are said to be damaged. When threads operate on damaged objects, arbitrary behavior can result. This behavior may be subtle and difficult to detect, or it may be pronounced. Unlike other unchecked exceptions, ThreadDeath kills threads silently; thus, the user has no warning that his program may be corrupted. The corruption can manifest itself at any time after the actual damage occurs, even hours or days in the future.

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧