javamultithreadingjvmschedulingpreemptive

Can we change the JVM Thread Scheduler?


Can we change the Thread scheduler of JVM? Suppose my JVM is working with preemptive scheduling of threads, then can I change it to my custom thread scheduling algorithm? or does JVM provide choices for the scheduler?


Solution

  • In general the JVM doesn't do any scheduling. That is the task of the OS. Linux for example has configurable scheduling options, and if you want to add a new scheduling strategy, you can change the kernel.

    However, depending on why you want to do this, you can solve the problem another way such as using a custom Executor, or a Reactor style framework, or effectively disabling scheduling for a CPU and doing all the work in Java yourself. (Not a trivial topic, rarely very useful)