Clase Thread - docencia de la ETSIT-URJC
Clase Thread - docencia de la ETSIT-URJC
Clase Thread - docencia de la ETSIT-URJC
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Condiciones <strong>de</strong> carrera<br />
¡ La sentencia <strong>de</strong> asignación NO se ejecuta <strong>de</strong> manera atómica !<br />
public c<strong>la</strong>ss Hucha {<br />
private int ahorros = 0;<br />
public void mete ( int cantidad ) {<br />
ahorros = ahorros + cantidad;<br />
}<br />
public int ahorros () { return ahorros; }<br />
}<br />
13 MOVE ahorros, A<br />
14 ADD A, cantidad<br />
15 MOVE A, ahorros<br />
<strong>Thread</strong> Pedro<br />
<strong>Thread</strong> Juan<br />
A cantidad PC ahorros<br />
0 1 13 0<br />
A cantidad PC ahorros<br />
0 1 13 0<br />
A cantidad PC ahorros<br />
1 1 14 0<br />
A cantidad PC ahorros<br />
1 1 15 1<br />
A cantidad PC ahorros<br />
0 1 13 1<br />
A cantidad PC ahorros<br />
1 1 14 1<br />
A cantidad PC ahorros<br />
1 1 15 1