java - What would be an efficient design for this use case -


I have an experiment case, where I'm starting a timer on a particular method, to see that Does it take longer than X seconds? If so, then I am logging in our logs as fatal.

  Private boolean is DpxTimedOut (stopwatch stopwatch) {stopWatch.stop (); Long-term time = stopwatch. Jetaneo Time (); Double lasting time in Ascendo = Aided Time / Nano_DivaIoOr; Return (elapsedTimeInSeconds & gt; = DPX_TIMEOUT_VALUE); } Public Zero callDPX () {tryWatch stopwatch = new stopwatch (); // body of law} hold (exception e) {e.printStackTrace (); } In the end {// enter a check here to see if the DPX has expired and then to enter a FATAL if (isDpxTimedOut (stopwatch) {log.fatal ("[dpx timeout] request from 12 seconds Took more time. "); }}   

Now I have a usage case where I have to keep this stup clock in different classes in many ways. How should I design this? Timeout for different classes will be different and they should be read from the config file. Can someone tell me in a good design for this use case.

Try something with these lines:

  class executioner { Public static zero execAndLogOnTimeout (runable runnable, long timeout) {// Start time runnable.run (save); // timeout time // took time & gt; Timeout: Log}} Executioner.exacandlogOntimeout (New Runnabel () {@ Override Public Wired Run}} {// Clock Code}}, Config TimeoutForThis Peace Encoder ());   

Another option would be to use AOP around the advice.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -