0

I want to send request from Client(Socket) to server with the interval of some time like maybe 5 minutes. Is there any workaround to achieve that. And the same thing is possible in Android or not ?

foxt7ot
  • 2,465
  • 1
  • 19
  • 30

2 Answers2

0

Well, you can use a Timer or a Thread

new Thread(new Runnable() {
        public void run() {
            while (true) {
                doStuff();
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }).start();
Tiago Engel
  • 3,533
  • 1
  • 17
  • 22
0

Yes you can achieve it using java.util.Timer and java.util.TimerTask.

Please have a look at below posts for samples:

Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76