Java: Best way to retrieve timings form multiple threads -


We have 1000 threads that affect a web service and how long the call takes. The application wants to return its own time results so that different data can be recorded. Please note that different devices were considered for this, but for many reasons we have to write our own. Each thread of what is the best way to come back on time for - we have to consider the two options so far: - 1. the result of a thread of time, this Singleton says that a sync to write to file Provides method. This ensures that write all threads file instead (though in a precarious order - which is fine), and since has been taken by the thread after the results of the call, be blocked again not wait to write Is actually an issue when all threads will be completed, the main application can read the file to generate statistics. 2. Using executable, callable and future interfaces which would be the best method, or are there any other better ways?

Use the latter method.

Applicable to your employees, repayable. Then you send them to a Threadpool, and get a future instance for each.

Then get the bus () on the futures to get the results of the calculations.

  Import java.util. *; Import java.util.concurrent. *; Public category WebServiceTester {Public Static Class Checker Callable {Public Integer Call} (Integer Start = Now (); // Your test here integer end = now (); Return end - start;}} Public static zero main (string algos [] ) Exceptions are thrown by {executive service pool = executable.newfixedThreadPool (1000); set & lt; future  

Comments