grzesiu988
grzesiu988

Reputation: 244

Spring call method in different thread

I have http controller, service A, service B. There is a http request. Controller method call method from A, A method call method from B. Controller -> A -> B

Threads and loaders:

Controller - [http-nio-8080-exec-7,5,main], TomcatEmbeddedWebappClassLoader
A - [http-nio-8080-exec-7,5,main], TomcatEmbeddedWebappClassLoader
B - [ForkJoinPool.commonPool-worker-3,5,main], jdk.internal.loader.ClassLoaders$AppClassLoader@6ed3ef1

Why call to B is in different thread and class loader? There is no async calls.

Upvotes: 0

Views: 331

Answers (1)

rubita
rubita

Reputation: 36

ForkJoinPool is implementation of ExecutorService. It parses a task to multiple smaller ones, runs in parallel threads & joins them once completed. So end result would seem synchronous. If there is no explicit call, then some internal library is using fork/join somewhere in the flow.

Upvotes: 1

Related Questions