0

We are trying to run multiple @Scheduled tasks in parallel (for ETL purposes). We are using Spring and Java 1.8 Tomcat/Catalina;

According to this article, adding the following to JAVA_OPTS will have the system aware of the cores, and run the tasks in parallel cores

-XX:+UnlockExperimentalVMOptions
-XX:ActiveProcessorCount=2

According to this SO answer, Java threads are dependent exclusively on the OS for thread-to-core management.

Nevertheless, TRACKING the processes in runtime is unclear to us. While getting the tread id using Thread.currentThread() - it is unclear how to detect which PROCESSOR (or core) we are running on.

Moreover, if our threads are "heavy" enough - we'd like to make sure they are executed exclusively on a single core (is that possible?)

Visibility is important for us, because the ability to actually observe the current core is a good indication that "everything works in parallel, and resources are distributed evenly". Rather without it, we have to examine the cpus manually with some manual monitoring app such as htop and alike.

Is it possible to control (and manage!) the cores participating in a multithreaded java application?

orberkov
  • 1,055
  • 2
  • 13
  • 26

0 Answers0