Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1.  
  2. public class MyTimer extends Thread
  3. {
  4.     private long startime;
  5.  
  6.     MyTimer(long start){
  7.         startime = start;
  8.     }
  9.     @Override
  10.     public void run()
  11.     {
  12.         try
  13.         {
  14.             do
  15.             {
  16.                 long miliseconds;
  17.                 miliseconds = System.currentTimeMillis() - startime;
  18.                 System.out.println("Прошло времени: " + (miliseconds / (1000*60)) % 60 + " : " + (miliseconds / 1000) % 60 + " : " + miliseconds % 1000);
  19.                 sleep(1);
  20.             }while(!this.isInterrupted());
  21.         }
  22.         catch(Exception e)
  23.         {
  24.             System.out.println(e.getMessage());
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement