Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java every second

Timer timer = new Timer();
timer.schedule(new TimerTask() {
  @Override
  public void run() {
    //what you want to do
  }
}, 0, 1000);//wait 0 ms before doing the action and do it evry 1000ms (1second)

timer.cancel();//stop the timer
Comment

java every second



class SayHello extends TimerTask {
    public void run() {
       System.out.println("Hello World!"); 
    }
}

// And From your main() method or any other method
Timer timer = new Timer();
timer.schedule(new SayHello(), 0, 5000);


Comment

PREVIOUS NEXT
Code Example
Java :: round jframe corners in java 
Java :: processing angle between two pvector 
Java :: Java JDK 11 ubuntu 
Java :: java swing make window not resizable 
Java :: marker annotations in java 
Java :: for with two values java 
Java :: java save file dialog 
Java :: how to create a button with javascri[t 
Java :: java android show toast 
Java :: react-native force rtl on android 
Java :: calculate age in days java 
Java :: springboot starter jpa 
Java :: add retrofit dependency android 
Java :: change port in spring boot 
Java :: filll 2d array in java 
Java :: print list in java 
Java :: java cast duration to long 
Java :: how to print a matrix in java 
Java :: convert java date to sql date 
Java :: hibernate dependency 
Java :: collision java 
Java :: printwriter java append to file 
Java :: javax notblank not working 
Java :: Could not find method compile() 
Java :: joptionpane.showmessagedialog 
Java :: java declare multilayred array values 
Java :: java string to int 
Java :: java double 2 decimal 
Java :: pyramid star pattern in java 
Java :: how to check if page in webview or not in android studio 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =