Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!