Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:一个奇怪的wait()问题? [Re:nov1]
rostone





发贴: 131
积分: 10
于 2003-07-15 13:27 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
nov1 wrote:
When a thread exits, it will issue a notify()/notifyAll() on objects from which it has occurred a lock.


Maybe it is correct.But it can not explain this phenomena.
If we comment the "synchronized" sentence as below:

class Calculator extends Thread
{
int total;
public void run()
{
System.out.println("Starting calculating ...");
/*
synchronized(this)
{
for (int i = 0; i < 100; i++)
{
total += i;
}
try
{
wait(1000);
}
catch (InterruptedException e )
{
}
}*/
}
}

The calculator thread didn't lock any object.So it would not call any notify as you expected when it expired.

But you can see the same result.




[转帖]面向对象的思维方法

话题树型展开
人气 标题 作者 字数 发贴时间
5719 一个奇怪的wait()问题? jiangns3000 2017 2003-07-09 19:24
5455 Re:一个奇怪的wait()问题? rostone 173 2003-07-11 10:17
5019 Re:一个奇怪的wait()问题? jiangns3000 28 2003-07-16 09:04
5002 Re:一个奇怪的wait()问题? nov1 378 2003-07-16 22:43
4995 Re:一个奇怪的wait()问题? jiangns3000 355 2003-07-17 08:31
4938 Re:一个奇怪的wait()问题? nov1 6 2003-07-17 09:08
5096 Re:一个奇怪的wait()问题? floater 130 2003-07-17 21:34
5057 Re:一个奇怪的wait()问题? jiangns3000 89 2003-07-14 11:08
5060 Re:一个奇怪的wait()问题? nov1 103 2003-07-14 19:50
5414 Re:一个奇怪的wait()问题? rostone 834 2003-07-15 13:27
5088 Re:一个奇怪的wait()问题? floater 909 2003-07-16 11:08
5084 Re:一个奇怪的wait()问题? jiangns3000 59 2003-07-14 22:24
5124 Re:一个奇怪的wait()问题? floater 740 2003-07-15 00:18
5081 Re:一个奇怪的wait()问题? nov1 388 2003-07-15 00:26
5009 Re:一个奇怪的wait()问题? jiangns3000 20 2003-07-15 10:20
4997 Re:一个奇怪的wait()问题? jiangns3000 88 2003-07-15 17:50
5056 Re:一个奇怪的wait()问题? nov1 3482 2003-07-15 22:23
5402 Re:一个奇怪的wait()问题? rostone 614 2003-07-16 09:38
5097 Re:一个奇怪的wait()问题? floater 4259 2003-07-16 11:29

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923