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