Java uses a thread to request access five consecutive times every 10 minutes, and then stops the request.
Java uses a thread to request access five consecutive times every 10 minutes.
Package com. qlwb. business. util;/***** @ class number: * @ Class Name: RequestTask * @ Content Abstract: If the developer sends a callback notification, but does not receive the OK response, developers need to retry five times, each interval of 10 minutes. * @ Author: Lu Weiwei * @ creation date: 4:25:20, January 1, April 15, 2016 * @ modifier: * @ modify Date: * @ modify description: brief description of the modified content * @ version 1.0.0 **/public class RequestTask implements Runnable {private String url; private String param; private String status = "false"; public RequestTask (String url, string param) {super (); this. url = url; this. param = param ;}@ Override public void run () {int I = 1; int max = 5; while (true) {String result = Http Request. sendPost (url, param); I ++; if ("OK ". equals (result) {status = "OK"; break;} if (I> max) {break;} try {Thread. sleep (10*60*1000); // each interval is 10 minutes.} Catch (InterruptedException e) {e. printStackTrace () ;}} public String getStatus () {return status ;}}