简体   繁体   中英

How to send HTTPClient post message with certain interval

I want to send http post message to the client (which i can do without any problem). But I want to send this message continously. Say for instance every 5 mintutes I want to send this message to client. Is there any way to do that? thanks in advance..

Probably, the easiest way is to use a ScheduledThreadPoolExecutor (attention, the following code will never exit):

    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            // your request code here

        }
    }, 0, 5, TimeUnit.MINUTES);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM