Hi all!
Im expiriencing some thread related problems with an applet game Im writing…
I have 3 threads running: the game thread itself, a keepalive thread that posts a message to the server each x seconds and an sound thread that pulls my musicplayer for sampledata frequently.
I found out that the applet’s paint seems to get called by the browser, in certain situations the browser seems to call the applet’s repaint in some sort of loop. This caused my sound thread to get too little priority which caused sound stutter. I was able do disable the browser repaints by setting: setIgnoreRepaint(true).
But I had to modify my run method too. Using the sleep() function halved my framerate, thread.yield() resulted in good fps but somehow i loose control after x secs and the whole applet goes beserk. When I call Thread.join(1) it seems to work ok, but I think thats not the proper way of doing this. I thought that join(1) waits 1 ms to kill the thread which doesn’t seems to be what i want. Also on slower systems the game thread seems to pause very shortly when I play an audioclip.
How should I implement the thread.yield() properly? It somehow just looses control after a variable period of time…
Thanks!
Thijs