initial commit
[applet-bots.git] / src / appletbots / WorldThread.java
blobc83641215e2fae1411d94c0d49f676cdceaf1864
1 /*
2 * Copyright (c) 2002 Erik Rasmussen - All Rights Reserverd
3 */
4 package appletbots;
6 /**
7 * This is the main thread that drives the changes in the world.
9 * @author Erik Rasmussen
11 public class WorldThread extends Thread
13 /**
14 * The world this WorldThread is running on
16 private World world;
17 /**
18 * Whether or not the thread is running or should continue running
20 private boolean running;
22 /**
23 * Creates a new world thread to run on the given world
25 * @param world The world the thread should run for
27 public WorldThread(final World world)
29 this.world = world;
32 /**
33 * Calls world.incrementTime() and sleeps for world.getDelay()
35 public void run()
37 running = true;
38 while (running)
40 world.incrementTime();
41 try
43 Thread.sleep(world.getDelay());
45 catch (InterruptedException e)
47 running = false;
52 /**
53 * Returns whether or not this world thread is running or should continue
54 * to run
56 * @return Whether or not this world thread is running or should continue
57 * to run
59 public boolean getRunning()
61 return running;
64 /**
65 * Sets whether or not this world thread is running or should continue to
66 * run
68 * @param running Whether or not this world thread is running or should
69 * continue to run
71 public void setRunning(final boolean running)
73 this.running = false;