Is it possible to set priority for the main thread?

As we know, even the main one is also a stream. So, just for curiosity, is it possible to set priority for the main thread?

+4
source share
3 answers

You tried

Thread.currentThread().setPriority(); 
+9
source

It is worth noting that this is just a hint of the OS, and if you are not an administrator or root, it may not do anything. Even then, this may not help much. setPriority () is a harmless AFAIK.

0
source

IIRC, usually setting the priority of a running thread, will have no effect. The old trick was to always start a new topic and abandon the main one. This is actually what the Sun / Oracle JVM now does for Linux to resize the stack.

Setting thread priority is usually a mistake. Many versions of the JRE completely ignore it.

0
source

Source: https://habr.com/ru/post/1334414/


All Articles