Sunday, July 4, 2010

Thread Priority

Java assigns to each thread a priority that determines how that thread should be treated with respect to the others. Thread’s priority is used to decide when to context switch from one running thread to the next.


ThreadName.setPriority(int number);

/* number from 1 to 10, 1 =MIN_PRORITY 5=NORM_PRIORITY 10=MAX_PRIORITY */

A thread can voluntarily relinquish control by using yield(). A thread can be preempted by a higher-priority thread.

No comments:

Post a Comment