Why is the priority of the thread set to the maximum in the loop in this java applet code?

I am trying to learn basic java programming for games.

I follow this tutorial here .

Their skeletal code for the run method in the applet:

public void run () 
{
    // lower ThreadPriority 
    Thread.currentThread().setPriority(Thread.MIN_PRIORITY); 

    // run a long while (true) this means in our case "always" 
    while (true) 
    {
        // repaint the applet 
        repaint(); 

        try 
        {
            // Stop thread for 20 milliseconds 
            Thread.sleep (20); 
        } 
        catch (InterruptedException ex) 
        {
            // do nothing 
        } 

        // set ThreadPriority to maximum value 
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY); 
    }
}

In this code, they first set the minimum priority for the stream. Then inside the loop they set the maximum value.

I was wondering what is the purpose of this?

0
source share
1 answer

I do not know why they decided to initially set priority. I think this is pointless.

However, setting the priority above the norm (maybe the maximum is an exaggeration) makes sense.

, , , , , , - , " , , " . , . Windows, , , " ".

, , Java, .

+2

All Articles