This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes How to start ,suspend, resume Thread in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "How to start ,suspend, resume Thread in java?" Watch "How to start ,suspend, resume Thread in java?" New topic
Author

How to start ,suspend, resume Thread in java?

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

This is merely impossible to bear. I do not know Java Threads at all. What is that?

Here is my primitive Thread:

As you see it is simple. Here is my code that starts thread :

This method creates SplashTooltipThread and executes run method once, then run sets isRunning to false(line 13) to stop executing run method.

However when I again call this method(sleepAndShowTooltip) I do not create SplashTooltipThread but instead I only set its variable isRunning to true. I expect that my SplashTooltipThread will again execute method run once. But it never happens. I print that splashTooltipThread.isRunning is true but splashTooltipThread does not execute its run method again.

What happened to while loop inside run method and why it does not see that I set back isRuning to true.

Thank you!


True person is moral, false is right!
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Oops!

I am sorry, this saturday evening. Do not read that nonsense, I need a rest
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to start ,suspend, resume Thread in java?
 
Similar Threads
Thread and variable value question?
Removing objects (Threads)
Simulating Power Supply Unit.
terminating one main class thru another mani class?
best way to kill ?