Article View: cn.bbs.comp.lang.java
Article #21372Re: ��ѧ�߹����߳�����~~~
From: SuPerDeBater�����������ۼ�
Date: Sat, 06 Dec 2003 15:21
Date: Sat, 06 Dec 2003 15:21
31 lines
3719 bytes
3719 bytes
�Ҿ���ѧϰJavaThreadӦ��������¼������⣺
1��wait/notify/notifyAll ��������synchronized method/code block�е��á�
2��Java��ÿ�������ж��������ԣ����������������Object class�ж���ģ��κ�
�����Ե��á�
JavaĿǰֻ֧�ֵ���������һ��Σ�����synchronized �����ܿ緽��ʹ�á���JDK1.5��
������ƣ�
3����ÿ��������Javaά�������أ�synchronized pool��waited pool��ǰ�ߴ������
synchronized method/block������̣߳�����Ҫ����-notify��ֻҪ�������ͷţ�
�Զ�������������ߴ�ŵ�����wait()������������̣߳���Ҫ����-notify����
4��Ҫ��ö�����ֻ�н���synchronized method/block��Ҫ�ͷŶ�������Ե���wa
it()�������˳�synchronized method/block
5��wait()��sleep()����������ǰ���ͷŶ��������߲��ͷš�
6����������application��ͨ��hard code��killһ���̣߳�����Ҫ��ô��������ʹ
��destroy()��������ʵ���������JDK��û��ʵ�֣�����һ���þͻ��׳��쳣��JDK����
ͨ������취���˳��̵߳ģ�
�� �� SmallX@bbs.pku.edu.cn (46"CoalBH;��ӭ�μӺ�ͿSmalllX��� �Ĵ������ᵽ: ��
: ����˵ synchronized ��ʵ����һ��������һ���߳̽����ʱ���Ͱ� synchronized
: ��Ķ������ֱ�����˿�ŰѶ��������ֹ�����߳����ڼ�ı�������
: //Java //Nature Language
: synchronized(obj){ lock(obj);
: ... <=> ...
: } unlock(obj);
: ��֪�����ĶԲ��ԣ�Java�������ĵ����˵�IJ������ס�
: ��ô��wait()��notify()��ʲô��˼������ôҪ�����Ƕ�� synchronized ��ߣ�
: �Ҿ��û��� resume(), suspend() �����һЩ��һ������һ���ָ�������Java������
: �ĵ����˵���Ƽ�������wait()��notify()����ʲô��˼����Ϊʲô������� synchronized
: .................������ʡ�ԣ�
--
[m[1;31m�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 218.1.31.110][m
Technical Details
Message-ID:
<49XZRD$90U@bbs.sjtu.edu.cn>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed.news2me.com!newshosting.com!news-xfer2.atl.newshosting.com!167.206.3.103.MISMATCH!news3.optonline.net!maily.cic.tsinghua.edu.cn!news.happynet.org!news.ccie.net.cn!SJTUShow Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: f6cb0,ef18faa692e03db6,start X-Google-Attributes: gidf6cb0,public X-Google-ArrivalTime: 2003-12-06 07:25:10 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed.news2me.com!newshosting.com!news-xfer2.atl.newshosting.com!167.206.3.103.MISMATCH!news3.optonline.net!maily.cic.tsinghua.edu.cn!news.happynet.org!news.ccie.net.cn!SJTU From: abnertan.bbs@bbs.sjtu.edu.cn (SuPerDeBater�����������ۼ�) Newsgroups: cn.bbs.comp.lang.java Subject: Re: ��ѧ�߹����߳�����~~~ Date: 06 Dec 2003 15:21:23 GMT Organization: ��ˮ˼Դ Message-ID: <49XZRD$90U@bbs.sjtu.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: Java/M.1070723101.A Lines: 31