Thread View: news.software.nntp
2 messages
2 total messages
Started by Ronnie Crittendon
Mon, 19 Mar 2007 00:54
Re: When the stop() in Thread class changed to final method?
Author: Ronnie Crittendon
Date: Mon, 19 Mar 2007 00:54
Date: Mon, 19 Mar 2007 00:54
82 lines
4227 bytes
4227 bytes
In article <epup7l$4o0$1@ctb-nnrp2.saix.net>, Rogan Dawes
<discard@dawes.za.net> wrote:
>RC wrote:
>> Daniel Pitts wrote:
>>> On Feb 1, 7:27 am, RC <raymond.c...@nospam.noaa.gov> wrote:
>>>> If you go to this link
>>>>
>>>> http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDepreca...
>>
>>>
>>> That document you linked to is suggesting that you override the stop
>>> method in Applet, not Thread.
>>
>> Then, do you know how I can stop a thread since Thread.stop()
>> has deprecated. Can I just make a thread = null?
Stopping a thread is just the worst possible thing
you can imagine. In many cases, you'll simply crash you
entire app if you don't catch that exception in
the right place.
Thread should be stopped by exiting it main run()
loop. The simpliest thing is to set some variable
that is tested in the run loop. That variable could
be set by just about any method or a result of
some user action, such as "cancel" or from some
event handler code.
But when you simply slaugher thread with stop(),
there may be all sorts of things happening
in your app, things may be locked, some other
threads may be waiting for some operation to complete,
and so on. Because once you even utter the word
"thread", it implies theare are other threads in
your app, and they all should coordinate the
access to common resources, such as files, sockets,
gui elements or you name it.
So...
What you are creating by doing that stop() thing,
is making your entire app inconsistent, when one
part thinks that it has a valid access to some
variable or resource, but the other part,
sitting on the same resource is dead.
You'll never make your program stable.
That is for sure.
Just about all you can achive with it
is an ugly hack.
My suggestion is to completely forget this idea,
because exiting thread properly is about the simpliest
thing in the world, at least in most cases.
And make sure that if that thread is associated
with some frame in your app, you first exit thread,
and then make sure to close that frame by doing
dispose().
This way, your entire program's logic
will operate as intuitively expected by the user.
Good luck.
>Did you not read the link that YOU provided above?
>
>It has all the advice and examples you need to answer that question.
>
>Rogan
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"We're concerned about AIDS inside our White House ...
make no mistake about it."
--- Adolph Bush,
Washington, D.C., Feb. 7, 2001
Re: When the stop() in Thread class changed to final method?
Author: Rev. 11D Meow!
Date: Mon, 19 Mar 2007 16:37
Date: Mon, 19 Mar 2007 16:37
9 lines
1958 bytes
1958 bytes
"Ronnie Crittendon" <sly@netcom.com> wrote in message news:8va2gi$5uk$4@bellsouth.net... > simpliest No wonder coders can't get it right the first time.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads