Java - performance of a scheduled method drops after removing a condition

I wrote a method processMetrics that loads new metrics if the files containing the data were updated since the last request. I wanted the method to get executed every 10 seconds so decided to use ExecutorService for that purpose.

However after I removed the check if (System.currentTimeMillis() - startTime.get() > MAX_TIME_IN_MILLIS) the execution takes much longer. For example when the method gets called for 10000000 iterations it takes a few seconds with the condition present and several minutes when it's commented as shown below.

I don't need to check how much time...

Read More »

By: StackOverFlow - Wednesday, 7 November

Related Posts