0

I have created a runnable class A which executes some task for me. I am submitting this class using ExecutorService so that I can execute these tasks in parallel.

The runnable class A calls another object B which sends an AsyncFuture request (future.get() one).

I am submitting separate objects of runnable class A to the ExecutorService, however, the object of class B is being referred by a bean (singleton). Can this cause issues in thread execution?

I am noticing that some of the objects of class A are not being executed by any thread.

I read something about using ThreadLocal but I am not sure if it's applicable here.

user2780757
  • 191
  • 1
  • 11
  • Usually the method calls on the singleton are thread safe, unless Object B singleton has a property that is being updated when the method on B is called. Could you post the code of the Class B? – Zeus Nov 09 '16 at 20:32
  • Can you show some code ? – pbajpai Nov 10 '16 at 06:07

1 Answers1

1

Referring to a singleton bean from different objects, albeit across separate threads does cause a bottleneck. The only solution that worked for me was to lookup this bean on A's initialization.

user2780757
  • 191
  • 1
  • 11