Animation advice; making menus higher priority to animation

I'd like some advice please, if anyone has any :)

I'm running an interactive animation - the animation contains 'nodes', and an animated, contextual menu appears around a node when you mouseover it.

I want to ensure that the menu animation is seen to be smooth (30fps, assuming CPU can take it, but let's ignore Pentium IIs for now :P ), and the interactive animation (which now lies behind the contextual menu) runs as fast as it can without hindering the menu animation.

What's the best way to achieve this? I know how to implement the 30fps etc; I know my Java. What I'm not sure about is thread priorities ... I already have a series of Thread.yield() calls in my interactive animation thread, but it still by no means guarantees that the menu will run as fast as I'd like. I've been warned that setting thread priorities can have unexpected results. Would I nonetheless be able to achieve what I want by setting a higher priority on the menu thread?

Thank You.

[1005 byte] By [KomodoDavea] at [2007-11-26 18:09:58]
# 1
And you were warned. . what?
ChuckBinga at 2007-7-9 5:42:05 > top of Java-index,Core,Core APIs...
# 2
We don't see your whole code structure but this may help: http://java.sun.com/developer/JDCTechTips/2005/tt0727.html
hiwaa at 2007-7-9 5:42:05 > top of Java-index,Core,Core APIs...
# 3

> And you were warned. . what?

I was warned that the relative speeds of threads with different priorities could fluctuate a lot, and that the priorities didn't guarantee any performance ratio between threads.

> We don't see your whole code structure but this may

> help:

> http://java.sun.com/developer/JDCTechTips/2005/tt0727.

> html

That's a very useful link, I'll give that a good read, thank you hiwa :)

If anyone else has any suggestions, or tips on using thread priorities, please post :o) Thank you.

KomodoDavea at 2007-7-9 5:42:05 > top of Java-index,Core,Core APIs...
# 4
If doing this in Swing then thread priorities are irrelevant as everything is done by the event thread. Even in the AWT things should be done by the event thread.
davidholmesa at 2007-7-9 5:42:05 > top of Java-index,Core,Core APIs...
# 5

> If doing this in Swing then thread priorities are

> irrelevant as everything is done by the event thread.

> Even in the AWT things should be done by the event

> thread.

Ah right, thanks David.

I figured out the best way to do it in the end. Basically I just needed to get round the problem of this one loop I have that performs calculations on a large number of 'Shape's. I just put a modulus test in for a threshold value calculated according to the set desired FPS, and a Thread.yield() is called when n % threshold == 0 .

Cheers everyone.

KomodoDavea at 2007-7-9 5:42:05 > top of Java-index,Core,Core APIs...