questão sobre threads  XML
Índice dos Fóruns » Certificação Java
Autor Mensagem
ana_abrantes
JavaGuru
[Avatar]

Membro desde: 29/08/2003 15:44:09
Mensagens: 238
Localização: São Paulo
Offline

What will happen when you attempt to compile and run the following code?

1 - Compilation but runtime error.
2 - Compilation and output of done at runtime
3 - Compilation but no output at runtime, the program will run and wait with no output.
4 - Compile time error

Ana

SCJP 1.4 - SCWCD 1.4
escordeiro
Java Ninja
[Avatar]
Membro desde: 20/08/2003 09:31:08
Mensagens: 257
Localização: Belo Horizonte
Offline

Acho que é o 1...o método payBill não é synchronized e está tentando dar wait (vai lançar uma exceção com mensagem "Current thread not owner").

Para chamar wait, notify ou notifyAll, um método precisa ser synchronized ou a chamada tem que estar dentro de um bloco synchronized.

Flickr
[Email] [Yahoo!] [MSN] [ICQ]
 
Índice dos Fóruns » Certificação Java
Ir para:   
Powered by JForum 2.1.8 © JForum Team