Specifications
Sun Services
Java™ Programming Language
Module 13, slide 9 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Thread Scheduling Example
1 public class Runner implements Runnable {
2 public void run() {
3 while (true) {
4 // do lots of interesting stuff
5 // ...
6 // Give other threads a chance
7 try {
8 Thread.sleep(10);
9 } catch (InterruptedException e) {
10 // This thread’s sleep was interrupted
11 // by another thread
12 }
13 }
14 }
15 }










