Threads inhibiting events?

So I have a piece of code that reads mousePressed and mouseReleased events. It seems to work fine for the most part. Then I decide I want to make a scroll bar scroll when a particular area is pressed, so I have flags set for if a button is being pressed. That's all good. The problem comes when I start a thread to 'scroll' the scroll bar (right now it just is printing text to say that it would be doing something). My problem is that when I start this thread, it doesn't stop. Ever. I release the mouse and it never sets the flags to false (so the mouseReleased code isn't being called because of the running thread. How do I fix this? Any help is appreciated.

publicvoid mousePressed(MouseEvent arg0)

{

int x = arg0.getX();

if(x<_boxes[1])

{

_flags[0]=true;

}

elseif(x>_boxes[4])

{

_flags[1]=true;

}

System.out.println("Repaint Now");

repaint();

System.out.println("Run Now");

_sc.run();

}

publicvoid mouseReleased(MouseEvent arg0)

{

System.out.println("Stop Now");

_flags[0]=false;

_flags[1]=false;

System.out.println("Repaint Now");

repaint();

}

}

class ScrollFunction

extends Thread

{

publicvoid run()

{

while(true)

{

try

{

System.out.println("Scrollage!");

Thread.sleep(1000);

}

catch(InterruptedException e)

{

e.printStackTrace();

}

}

}

}

[2811 byte] By [juckelea] at [2007-10-2 17:09:42]
# 1
Oh, sorry, there's an error in my post above. The thread has the line while(true), however this doesn't stop the problem that I have that I still am not ever executing the mouseReleased code.
juckelea at 2007-7-13 18:24:37 > top of Java-index,Security,Event Handling...
# 2
Oh, I solved my problem. I need to write the action into Run and then use the method .start().
juckelea at 2007-7-13 18:24:37 > top of Java-index,Security,Event Handling...