thread question : how to impose the Main-*** queue instead of the awt-eventqueue

Hi all

I want some actions to take place in a Main-***** thread and not in a AWT-EventQueue-*** thread

but those actions are targetted by a JMenuItem, and thus follow the AWT event pathway

What I do know is launch a Thread from the main() with a
run()
{
while(true)
{
if(flag)
{
//do the actions
flag = false;
}
yield();
}
}

and the JMenuItem sets the flag to true, when i need the code to be executed

the problem is that the while(true) yield(); take 100% of the CPU (though it is not realy slowing the computer)

but if a start/stop the thread just when i need instead of starting it withing the main(), it ends up in the AWT-EventQueue, and that is bugging the display() thread of my renderer

thx for any clue

You can suspend a Thread until it is roused. Take a look at Object.wait() and Object.notify() in the JDK documentation. Hope it helps.

Also, for a simpler solution take a look at the new concurrent locks API, particularly Semaphore. Its way easier to use.