February 2014
Beginner
1248 pages
62h 25m
English
Class PrintTask (Fig. 23.3) implements Runnable (line 5), so that multiple PrintTasks can execute concurrently. Variable sleepTime (line 8) stores a random integer value from 0 to 5 seconds created in the PrintTask constructor (line 17). Each thread running a PrintTask sleeps for the amount of time specified by sleepTime, then outputs its task’s name and a message indicating that it’s done sleeping.
Read now
Unlock full access