Threads

4 respostas
M

la vai uma básica de threads.. qual é a saida?

public class Foo {

	 public static void main( String args[] )
	 {
		  T1 t = new T1();
		  
		  t.start();
		  
		  synchronized( t ) 
		  {	  
			  try {
	
					t.wait();
					System.out.println( "a" );
	
			  } catch ( InterruptedException e ) { }
		  }
	 }
}

class T1 extends Thread {

	 public void run()
	 {
		  synchronized( this )
		  {
				System.out.println( "b" );
				notify();
				System.out.println( "c" );
		  }
	 }

}

4 Respostas

F

b
a
c

???

Porfavor alguém depois explica :???:

M

“Fabio_Mendes”:
b
a
c

???

Porfavor alguém depois explica :???:

errou. hehee :slight_smile: , mais alguém?

H

b
c
a

pois o notify só surtirá efeito após a thread liberar o lock, o que ocorrerá no } do método run.

M

“hipersoft”:
b
c
a

pois o notify só surtirá efeito após a thread liberar o lock, o que ocorrerá no } do método run.

yeah! :cool:

Criado 17 de setembro de 2004
Ultima resposta 19 de set. de 2004
Respostas 4
Participantes 3