Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package runners;
- public class Runner implements Runnable
- {
- private String runnerID;
- public static final int COUNTER = 100;
- public Runner(String id)
- {
- runnerID = id;
- }
- public String toString()
- {
- return runnerID;
- }
- public void run()
- {
- int metresRun = 0;
- while(metresRun < COUNTER)
- {
- try
- {
- metresRun++;
- Thread.sleep((long)(Math.random() * 10));
- System.out.println(runnerID + " has run " + metresRun + " metres");
- }
- catch(InterruptedException e)
- {
- e.printStackTrace();
- }
- }
- System.out.println(runnerID + " has arrived!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement