Sub-threading Instructions Reflow

Source: Internet
Author: User
Tags date now getmessage

public void Run () {Countdownlatch countdownlatch = new Countdownlatch (1); try{try{if (!  GlobalConstants.IB_GATEWAY_LOG_URL.equals (LogURL)) {logger.info ("change LOG URL: \ n old: {} \ n NEW:                    {} ", LogURL, Globalconstants.ib_gateway_log_url); Read the log if (LogURL! = null &&! ") that was left after the last read before the restart.                        Equals (LogURL)) {int res = readlogfile (logurl);                            if (res = = 0) {logger.info ("read last restart Success");                        Anotherday = false;                        } else if (res = = 1) {logger.info ("Last restart File not found");                        } else {logger.info ("Last restart file read fail");                }} logurl = Globalconstants.ib_gateway_log_url;  }} catch (Exception e) {              Logger.error (E.getmessage (), E);            } finally {Countdownlatch.countdown ();            } countdownlatch.await ();            Countdownlatch = new Countdownlatch (1);            Determine if the next day, date now = new Date ();            String Stnow = Dateonly.format (now);            String Stformer = Dateonly.format (startTime);                if (!stnow.equals (Stformer)) {//Description the next day, activate the next-day read mechanism anotherday = true;            Logger.info ("Another Day");                    } try{if (anotherday) {String logurltemp = LogURL;                    int index = Logurltemp.lastindexof (".");                    StringBuilder StringBuilder = new StringBuilder (100);                    Stringbuilder.append (logurltemp.substring (0, index+1)). Append (Dateibformate.format (StartTime)). Append (". Log");                    int res = Readlogfile (stringbuilder.tostring ());     if (res = = 0) {                   Logger.info ("Read yesterday success");                    Anotherday = false;                    } else if (res = = 1) {logger.info ("Yesterday File not found");                    } else {logger.info ("Yestoday file read fail");            }}} catch (Exception e) {logger.error (E.getmessage (), E);            } finally {Countdownlatch.countdown ();            } countdownlatch.await ();        Readlogfile (LogURL);        } catch (Exception e) {logger.error (E.getmessage (), E); }

  

The last line appears before Countdownlatch is used

Readlogfile

Data is inserted prior to the previous code data, so in order to ensure data ordering, join Countdownlatch

The nature is somewhat like: https://www.cnblogs.com/silyvin/p/9106641.html

Sub-threading Instructions Reflow

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.