How to set or change priority of Main Thread?

As already specified, you need to use setPriority() and getPriority() methods of Thread class to change and to retrieve priority of a Thread. However, first we need to get the Thread object of main Thread. This can be achieved using Thread.getCurrentThread(), which returns Thread object of the current Thread. Below is snippet of code

public class MainThreadPriority {
	public static void main(String[] args) {
		Thread t = Thread.currentThread();
		
		System.out.println("Priority of "+t.getName()+" thread is: "+t.getPriority());
		
		t.setPriority(Thread.MAX_PRIORITY - 2);
		
		System.out.println("Now, Priority of "+t.getName()+" thread is: "+t.getPriority());
	}
}

You may also like to read:
All Threads examples