Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TimerEx {
- public static void main(String args[]) {
- Timer timer;
- timer = new Timer();
- TimerTask task = new TimerTask() {
- int tic=0;
- @Override
- public void run()
- {
- if (tic%2==0)
- System.out.println("TIC");
- else
- System.out.println("TOC");
- tic++;
- }
- };
- // Started from 10 milis, then i launch it every 10000
- timer.schedule(task, 10, 1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement