Java uses a thread to request access every 10 minutes in a row 5 times, receiving the appropriate time to stop the request
PackageCom.qlwb.business.util;/** * * @ class Number: * @ class Name: Requesttask * @ Content Summary: If the developer sends a callback notification, but does not receive a reply OK response, the developer needs to retry 5 times, each time interval 10 minutes. * @author: Lu Weiwei * @ created: April 15, 2016 4:25:20 * Modified by: * @ Modified: * @ Modify Description: Simple description of Modified content * @version 1.0.0 * */ Public class requesttask implements Runnable { PrivateString URL;PrivateString param;PrivateString status="false"; Public Requesttask(string url, string param) {Super(); This. url = URL; This. param = param; }@Override Public void Run() {inti =1;intMax =5; while(true) {String result=httprequest.sendpost (URL, param); i++;if("OK". Equals (Result) {status="OK"; Break; }if(i > Max) { Break; }Try{Thread.Sleep (Ten* -* +);//10 minutes per interval. }Catch(Interruptedexception e) {E.printstacktrace (); } } } PublicStringGetStatus() {returnStatus }}
Java uses a thread to request access every 10 minutes in a row 5 times, then stops the request