Java uses a thread to request access five consecutive times every 10 minutes, and then stops the request.

Source: Internet
Author: User

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 ;}}

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.