The first suggestion will just not work - when a thread is dead, it stays
dead.

The second suggestion I would consider. I don't see what is particularly
tricky about it.

A third suggestion is to have a thread that loops, and in the loop have an
if statement that tests a boolean variable. If it is false, don't do
anything. This flag should be volatile, and your start/stop buttons need
only change its value, for you to achieve the desired effect. You may need
to sleep for a bit if the animation is stopped (to prevent CPU overload) -
but, suck and see.

BTW, this is NOT a Swing-related question. I guess I should give up now, WRT
ppl politely observing the wishes of listmembers, though.

-----Original Message-----
From: Singh,Gary - PLANO <[EMAIL PROTECTED]>
To: 'D. Michael Nelson ' <[EMAIL PROTECTED]>
Cc: '[EMAIL PROTECTED]' <[EMAIL PROTECTED]>
Date: Thursday, June 21, 2001 07:01
Subject: RE: Animation Thread?


>Two ways I can think off. In your run method you will have to set up a flag
>which is checked
>
>say you can put the entire thing in say
>
>while( flag )
>{....
>}
>
>So your run methods exits when the flag is put to false in the
>actionPerformed() method of the mouseListener on your buttons.
>
>OR :  have the mouseListener call
>
>your own start and stop methods which causes this thread to stop and start
>by calling Thread.wait() and notifyAll() ( mind you these have to a lock of
>some object or else the complier will complain...). Slight tricky here so
be
>slightly careful in implementation
>
>Thanks and Regards,
>Gary Grewal
>
>
>
>-----Original Message-----
>From: D. Michael Nelson
>To: [EMAIL PROTECTED]
>Sent: 6/20/01 12:19 PM
>Subject: Animation Thread?
>
>Hello,
>
>I have created a thread that runs an animation.   I want to add two
>JButtons
>to the application that will start and pause the animation thread.  I am
>uncertain how to pause the animation thread or resume it?  Any ideas?
>
>Thanks In Advance,
>D. Michael Nelson
>
>
>_______________________________________________
>Swing mailing list
>[EMAIL PROTECTED]
>http://eos.dk/mailman/listinfo/swing
>_______________________________________________
>Swing mailing list
>[EMAIL PROTECTED]
>http://eos.dk/mailman/listinfo/swing

_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to