🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #24467

Re: chat room ֮����һ

#24467
From: diff.bbs
Date: Thu, 08 Jan 1998 00:00
48 lines
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()Ҳ��ֹ�ˡ�


--
 ��Դ: ����������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-mail

Show 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,