Made a class to make it easier to synchronize with Swing's thread.