Computing.Net > Forums > Programming > 'reset' a thread in Java?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

'reset' a thread in Java?

Reply to Message Icon

Name: neal
Date: December 23, 2008 at 07:07:57 Pacific
OS: vista business SP1 3
CPU/Ram: athlon64x2 6000+/4GB
Product: - / -
Comment:

Hi,
I'm writing a game in which the character has an ability that has to 're-charge', and I was wondering if it is possible to reset a thread. I have written a method inside a thread that handles what the ability does when it is run, including the re-charge delay.
What I want to do is to be able to leave the thread object instantiated, and just call the run method again when the delay is up (currently recorded by a boolean). Currently, that gives an error; the thread has finished its execution and doesnt want to run again, but is there a way that i could be run again?
Thank you



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: December 23, 2008 at 07:59:17 Pacific
Reply:

<code>
public void run()
{
while bRunning=true
{
char.init();
timeout=0;
while bSuspend=false
{
char.recharge();
sleep(100)
if (timeout++=100)
bSuspend=true;
}
}
}

</code>


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: 'reset' a thread in Java?

reseting variable in java www.computing.net/answers/programming/reseting-variable-in-java/334.html

To allow a thread sleep for microseconds www.computing.net/answers/programming/to-allow-a-thread-sleep-for-microseconds/20063.html

Animation with Threads in Java www.computing.net/answers/programming/animation-with-threads-in-java/12378.html