4

I'm using invokeAll(callables, 30, TimeUnit.SECONDS); to spam out a bunch of async threads, then I go through the List<Future<Result>> to see which were completed, grabbing their results, and which were cancelled due to the timeout.

However, I'd really like to know where the code was when it was cancelled. I've got threads that aren't finishing in time and I'm having a difficult time figuring out where they're stuck (each Callable does a bunch of stuff).

Is there some way to get the line of code or the stack at the point the Future was cancelled? Not that I can see with Future, but maybe some other ancillary helper classes that'd help me track down where? Otherwise, I'm back to old-skool throwing debug log lines all over the place.

Using Java 11.

Chris Kessel
  • 5,583
  • 4
  • 36
  • 55
  • 1
    Found these 2 answers that might be related and helpful. [Handling Exceptions for ThreadPoolExecutor](https://stackoverflow.com/questions/2554549/handling-exceptions-for-threadpoolexecutor/34640459#34640459) & [Whether to use invokeAll or submit - java Executor service](https://stackoverflow.com/questions/34440604/whether-to-use-invokeall-or-submit-java-executor-service) – hydroPenguin Nov 11 '19 at 21:02

0 Answers0