Article View: cn.bbs.comp.lang.java
Article #24467Re: chat room ֮����һ
From: diff.bbs
Date: Thu, 08 Jan 1998 00:00
Date: Thu, 08 Jan 1998 00:00
48 lines
1877 bytes
1877 bytes
Hi Gao,
the stop() method causes that thread to terminate by throwing an exception. But to
provide a clean thread shutdown, you have to give to the thread the opportunity to
cleanup its resources. Like:
public void run() {
try {
//***do what you want
}
catch( ThreadDeath td ) {
//***cleanup all the resources: close the streams, socket, etc...
//***don't forget to rethrow the exception catched
throw td ;
}
catch( .... ) { //***catch the other exceptions... for example IOException
if you use a FileStream in the try block...
...
}
}
The destroy() method terminate thread immediately, without cleanup ( without
throwing exception ).
Hope it'll help...
...Yagiz...
--
+----------------------------
| Yagiz ERKAN
|
| Application Engineer
| RAND Software
| F R A N C E
|
| yerkan@rand.fr
+-----------------------------
���и����ԵĴ������ڶ�destroy()������ϣ�(��ԭ��Ҳ��ô
������������)��������JWolf��˵ destroy()��ʲô�����ɵģ�
��Ҫ��sun�Ӱ�ȫ�Կ��ǣ�������ϵͳ���������ɴ���stop().supend()
resume()Ҳ��ֹ�ˡ�
--
[1;36m ��Դ: ����������BBSվ��bbs.nease.net�E[FROM: www-post@bbs.nease.n]
Technical Details
Message-ID:
<3MRFhX$80e@bbs.nease.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f6cb0,f4e925659d041700,start X-Google-Attributes: gidf6cb0,public From: diff.bbs@bbs.nease.net () Subject: Re: chat room ֮����һ Date: 1998/01/08 Message-ID: <3MRFhX$80e@bbs.nease.net> X-Deja-AN: 313781101 X-Filename: Java/M.884219697.A Organization: Net Ease Newsgroups: cn.bbs.comp.lang.java,