I’ve managed to narrow down a problem to the following:
Whilst the AWT event thread is running, it often gets scheduled exclusively - ie. other threads get ZERO running time, for periods of up to 2 seconds. This is on a 1.5Ghz machine; on machines less than 1Ghz, it can get exclusive for tens of seconds.
Unless I’m mistaken, this is not a feature, it’s a bug. I’m testing mainly on Windows XP, and since when did XP do 10 second long thread starvation? My other thread(s) (I can reproduce with either multiple specialized threads, or with all functions located in one thread) do everything from cpu-intensive calculations through to painting on Graphics. There is no reason why they should get starved for tens of seconds.
Note: I am doing almost NOTHING in the EventThread, during actionPerformed calls. On linux, I spend less than 30 millis in my code over the course of 30 seconds. On Windows XP, I spend over 1000 millis in my code during actionPerformed. The only method calls I’m making are constructors for Point objects.
Even if removing those constructors reduces the time spent in the AWT event thread, this surely does NOT justify thread starvation?
I have asked Sun about why they have a tutorial webpage that is completely wrong (the tutorial on threading, specifically the page talking about scheduling, which is directly conflicting with some of the things stated in the 1.4.x release notes, and perhaps others too), AND how they are actually implementing thread-scheduling under windows (is it native, or simulated?), but have had no response in 2 months. !?!?
I’m asking here in case I’ve done something stupid, or possibly made a silly mistake. Otherwise, this does appear to be a major bug in the windows JVM. Or do you disagree? What am I misunderstanding here?