Using Timers in Java
Threads can be confusing, and multithreading isn't any better either. The use of timers is very simple JAVA milliseconds in a year Programme and allows several to work at the same time, with different hours without interruption. The first thing you need is an import package: import javax.swing.Timer; Then state the timer: Timer tmrTest = new timer (1, myTimer); 1 is the interval in milliseconds. This means this timer runs once every millisecond, fast. myTimer is just the name of ActionListener. Starting a timer is also required. Perhaps it is best to do this with a basic method. tmrTest.start (); // There is also a tmrTest.stop (). tmrTest.pause () and various other methods such as finding the current beat time and setting the speed. Next are the action listeners, who are in the core class and are allowed to move around the class. ActionListener myTimer = new ActionListener () // Notice how the second timer parameter is named, not the name of the timer! {