Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
Java single thread of execution and cpu cache

Assume my application has only one thread and the platform on which the application runs has several CPUs. It is possible that the single thread of application at some point of time executes on cpu A , reads the value of property X, modifies its value and the modified value of property X is not committed to main memory, it just resides on cpu registry or cache. Then after some time the same thread of application can continue its flow on cpu B, read the value of property X and get the stale value from main memory, as the updated value resides on cpu A registry/cache.

So till now i saw everywhere that such kind of visibility problems occur only in multithreaded apps but seems that in case i have described that is possible as well.

Any idea ?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The Java language definition says there is a "happens before" relationship between anything that happens earlier in a thread and anything that happens later in the same thread. This means that it is the responsibility of the JVM, working with the operating system, to ensure visibility of any data written earlier in the thread to any operations later in the same thread. On most operating systems, I believe this would be handled at the operating system level, by saving register state and flushing cache to memory when a thread is switched out. In any case, you don't have to worry about it when writing Java code.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda