Pergunta de entrevista da empresa Nexmo

Is this class thread safe? class X { int counter; X() { counter = 0;} public int incrementAndGet() { return counter++; } }

Resposta da entrevista

Sigiloso

13 de nov. de 2018

It's not thread safe, because the ++ operator is not atomic.

1