Selfish Scheduling


This applet runs two threads with the same priority that do not stop or yield. RaceTestApplet is based on RaceTest, but it extends Applet and uses SelfishRunnerTextArea instead of SelfishRunner. SelfishRunnerTextArea merely writes to a TextArea widget as well as stdout.

The really interesting thing here is that on certain platforms the output is different depending on whether RaceTestApplet was run as an applet or an application. For example under Solaris2.5.1 with JDK1.1.4 and green threads, we get:

cxh@carson 123% java -green  RaceTestApplet
Selfish: Thread #0, tick = 50000
Selfish: Thread #0, tick = 100000
Selfish: Thread #0, tick = 150000
Selfish: Thread #0, tick = 200000
Selfish: Thread #0, tick = 250000
Selfish: Thread #0, tick = 300000
Selfish: Thread #0, tick = 350000
Selfish: Thread #0, tick = 400000
Selfish: Thread #1, tick = 50000
Selfish: Thread #1, tick = 100000
Selfish: Thread #1, tick = 150000
Selfish: Thread #1, tick = 200000
Selfish: Thread #1, tick = 250000
Selfish: Thread #1, tick = 300000
Selfish: Thread #1, tick = 350000
Selfish: Thread #1, tick = 400000
cxh@carson 124% 
I believe that the reason for this is that the applet has multiple threads running.
The output you see below varies wildly, depending on what browser you are running and the operation system.


If your browser recognized the applet tag, you would see an applet here.


Back to the Threads page.
Copyright © 1997, The Regents of the University of California. All rights reserved.
Last updated: 10/09/05, comments to: cxh at eecs