logo

Crowdly

Teniendo el siguiente monitor que usan 3 hilos (H1, H2 y H3) en paralelo: publ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Teniendo el siguiente monitor que usan 3 hilos (H1, H2 y H3) en paralelo:

public class SynchronizedCounter {

private int c = 0;

public synchronized void sumar()

{

     c++;

}

public synchronized void restar()

{

     if (c==0) {

          wait();

     }

     c--;

}

}

Y sabiendo que el hilo principal ha hecho join a la espera de que los tres hilos terminen, que c vale 0, que el hilo H1 ha ejecutado el método restar() y que H3 tiene el monitor mientras ejecuta la línea "c++;" de sumar(), ¿cuántos hilos hay en total bloqueados en esta situación después de que H2 llame a sumar()?

0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.upm.es?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!