Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda