[3834] in java-interest

home help back first fref pref prev next nref lref last post

Thread Scheduling in Win32

daemon@ATHENA.MIT.EDU (David Strauss)
Wed Nov 29 07:45:50 1995

Date: Wed, 29 Nov 1995 06:13:06 -0500 (EST)
To: java-interest@java.sun.com
From: dstrauss@panix.com (David Strauss)

There's an applet called RaceTest that accompanies the section on
thread priorities in the Java Progammer's Guide.  It creates two
"Runner" threads whose run method is a loop that counts up to
400K.  The runners do no I/O so they should not block.  There is a
higher priority thread that occasionally wakes up and reports the runers'
progress.

According to both the Java and Win32 documentation, thread scheduling
is done only among those threads that are at the  highest
priority level of all currently runnable threads.  Thus, if you
set the runners to different priorities, the lower priority
runner should be "starved out" until the higher one finishes.
This is clearly not happening when I run the applet in Windows 95.
Although the higher priority runner always wins by a large margin,
the lower priority thread manages to butt in every once in awhile and
bump its count a few ticks.

This behavior is contrary to both the Java and the Win32 specs.  Does
anybody know what's going on?  (I did discover that the 10 Java 
priorities are mapped to only 6 Win32 priorities and I am
definitely assigning different Win32 priorities to the runners,
so it has nothing to do with that.)

-- 
------------------------------------------------
David Strauss
E-mail: dstrauss@.panix.com 
        dstrauss@lehman.com 
-------------------------------------------------

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post