I don''t know what i''m doing wrong!!!
The only thing i can think of is when stop is called..somehow it''s called twice? which makes the thread not start the next time start() is called.
The Problem is when i put my mouse in the window it starts running the thread okay.
when i take out the mouse it stops the thread as it supposed to...
but when i put the mouse back in again it doenst'' restart the thread?
any suggestions?
(any coding tips will be helpfull to)
Here''s the relevant code i think.
Public boolean mouseEnter(Event evt, int x, int y)
{
try
{
m_tthread.start(); //the thread is member of the main class
} //as in, m-tthread = new Thread(this);
catch (IllegalThreadStateException itse)
{
System.out.println(itse.toString());//don''t know if this
} //works it never
//showed up
return true; //so it returns and no other calls are made right
//even if it didn''t handle it correctly
Public boolean mouseExit(Event evt, int x, int y)
{
if (m_tthread.isAlive())
{
m_tthread.stop();
}
return true;
}
Public void run()
{
while (true)
{ //TimeIn is just an object member in the main class.
TimeIn = Long.toString(System.currentTimeMillis());
try
{
repaint();
Thread.sleep(250);
}
catch (InterruptedException ie)
{
m_tthread.stop();
}
}
}

Well, if I understand what you're asking properly, the problem is this: You can't start a thread that's already been stopped.

Hmm... I'm not explaining well. Once a thread has been run with its start() method, it can't be started again. You have two options: Either create a new thread each time you want to run it, or set some sort of pause() and unpause() methods in your class.

The second is probably preferable, as far as system resources go. It shouldn't be too much trouble to rig up something with wait(), notify(), and some flag. Maybe something like this:

private boolean paused = false;

run() {

//start your while loop here, then follow immediately//with this block: