Home : Course Map : Chapter 8 : Java :
Scheduling & Priority
JavaTech
Course Map
Chapter 8

Introduction
Threads Overview
  Demo 1   Demo 2
Stopping Threads
Multi-Processing
Thread Tasks
Animations
 
 Demo 3   Demo 4  
  Demo 5

Non-interacting
  Demo 6

Task Splitting
  Demo 7

Exclusivity
  Demo 8

Communicating
  Demo 9

Priority/Scheduling
More Thread

Exercises

    Supplements
Java2D Animation
  Demo 1 
Processor View
More Concurrency
Cloning
  Demo 2  Demo 3 

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

The determination of when threads run is left up to the JVM implementation to allow maximum flexiblity for the various applications of Java.

Threads are assigned priorties between 1 (lowest) to 10 (highest). A thread can set its own thread up or down in priority. Three standard priority values are defined:

  MIN_PRIORITY
  NORM_PRIORITY
  MAX_PRIORITY

For example,

  ...
  Thread threadX = new Thread(this);
  threadX.setPriority (Thread.NORM_PRIORITY + 1);
  threadX.start ();
  ..

For threads at the same priority, once one of them starts running, it continues until one of the following happens:

  • Sleeps - sleep() or wait() called
  • Waits for a lock in a synchronized method
  • Blocks on I/O such as a read()
  • Yields control with a yield() call
  • Terminates - e.g. returns from run()

As discussed earlier, preemptive or time-slicing context switching, which is available on some JVMs, also will move threads of the same priority in and out of the virtual processor

 

 

 

 

Latest update: Nov. 8, 2004

 

              Tech
Timers
  Demo 1
Hist. Adapt Range
  Demo 2
Sorting in Java
  Demo 3
Histogram Median
  Demo 4
Refactoring
  Demo 5
Error Bars
  Demo 6
Exercises

           Physics
Least Squares Fit
  Demo 1
Fit to Polynomial
  Demo 2
Fit Hist Errors
  Demo 3
Discretization
  Demo 4
Timing
  Demo 5
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.