Saiyine
Punto Com

Adjusting the priority of threads in Java

2007-08-23 12:14:10

With the next code we'll be able to control the priority our Java program's threads run.

    Thread me = Thread.currentThread();
    me.setPriority(Thread.MIN_PRIORITY);

For the example we've used the minimun priority, so every other process will have preference for CPU time but this. To check the others priority levels, look at the Thread object with an object inspector, or use an IDE with the ability of showing avaliable methods as you program, like Eclipse.

There's a problem: JDK has 10 priority levels, while every OS has its own number. For example, Windows NT has seven and is not uncommon for a Unix system to be in the hundreds. The best approach is to stick to MAX_PRIORITY, NORM_PRIORITY and MIN_PRIORITY within the code.

Rollos antiguos

2007-08-23 12:13:41 - Controlar la prioridad de los hilos en Java.

2007-08-23 09:05:46 - Sin novedad en la playa.

2007-08-14 04:15:28 - El pagar se va a acabar.

2007-08-03 04:15:22 - Post con retraso.

2007-07-29 04:00:47 - Noticias, nuevas y novedades.

Saiyine

Selfie of meHi! Welcome to Saiyine Punto Com where I talk about anything that goes through my mind!

Puedo prometer y prometo que a la mayor brevedad aquí irá un menú o algo asín.