Java uses a thread to request access every 10 minutes in a row 5 times, then stops the request

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.