How to use spring transaction in multithread

No, methodB() will not be executed in the same transaction as methodA(). Spring’s @Transactional only works on a single thread – it creates a session when a thread first enteres a method with @Transactional (or a method in a class with @Transactional), and then commits it when it leaves that method.

In your example, the transaction will end after you schedule the job in the thread pool. methodB() will have it’s own transaction.

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.