public class TimeSlicer extends Thread { int sleeptime; public TimeSlicer() { this(100, Thread.NORM_PRIORITY); } public TimeSlicer(int sleeptime) { this(sleeptime, Thread.NORM_PRIORITY); } public TimeSlicer(int sleeptime, int priority) { super("TimeSlicer"); this.sleeptime = sleeptime; if (priority < Thread.MIN_PRIORITY) priority = Thread.MIN_PRIORITY; if (priority > Thread.MAX_PRIORITY) priority = Thread.MAX_PRIORITY; setPriority(priority); } public void run() { while (true) { try { sleep(sleeptime); } catch (InterruptedException e) { } } } }