0

I want to implement a function which will be refreshed in every 10 second in server side using java - netbeans

I have a counter in my function which should be refreshed depend on the time .

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Azin
  • 21
  • 3

1 Answers1

1

Look into using the Java Timer class. This class can execute a TimerTask for a specified interval.

Documentation: http://docs.oracle.com/javase/7/docs/api/java/util/Timer.html

Example:

 import java.util.Timer;  //Be sure to import the correct Timer
 ...
 Timer timer = new Timer();
 timer.schedule(new CustomTimerTask(), seconds * 10000);

Your CustomTimerTask will be a class which extends TimerTask and implements a run method. The run method will be called every 10000 miliseconds as specified.

Complete Example:

http://www.java2s.com/Code/Java/Development-Class/UsejavautilTimertoscheduleatasktoexecuteonce5secondshavepassed.htm

chrissukhram
  • 2,957
  • 1
  • 13
  • 13