class MoveThread extends Thread { protected JogDial jd; public MoveThread(JogDial jd) { this.jd = jd; this.start(); } public void run() { long ts = System.currentTimeMillis(); while(true) { try { jd.moveBeadRight(); Thread.sleep(10); if (System.currentTimeMillis() - ts > 3000) { jd.snapBeadCenter(); ts = System.currentTimeMillis(); } } catch(Exception e) { } } } }