Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6949215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:55:29+00:00 2026-05-27T13:55:29+00:00

I want to know whether creating a new thread in Java triggers a cache

  • 0

I want to know whether creating a new thread in Java triggers a cache flush. Suppose I do something like this, in this sequence:

  1. A thread runs and sets a variable X.
  2. The thread creates a new thread.
  3. The new thread accesses X.

My question is this: is the new thread, either at the time it is created or at the time it begins execution, guaranteed to see the update made to X by the old thread in step 1? I understand that if the old thread changes the value of X in the future, it is not guaranteed that the new thread will see these changes. That’s fine. I just want to know whether the new thread will see the right values when it starts without need for explicit synchronization.

When I first decided to look into this topic, I thought a simple google search would immediately reveal the answer, but for some reason, I can’t find any result that addresses this question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:55:30+00:00Added an answer on May 27, 2026 at 1:55 pm

    Yes, it is.

    In java, there is ‘happens-before’ relation that specifies what memory effects are visible between two actions. If “A happens-before B”, then action B is guaranteed to see all changes done by action A.

    Starting a thread creates ‘happens-before’ relation between “thread.start()” call and all code that executes on new thread. New thread is therefore guaranteed to see memory effect of changing variable X on first thread.

    For quick overview of happens-before relation, see Memory Visibility part of java.util.concurrent package overview. In your case, interesting bits are:

    • Each action in a thread happens-before every action in that thread that comes later in the program’s order.
    • A call to start on a thread happens-before any action in the started thread.

    More links if you are curious:

    • Java Memory Model is described in Chapter 17 of the Java Language Specification
    • Java Memory Model FAQ
    • Everything else about JMM
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python, I want to know whether Java is installed.
This is my first app with CI and I want to know whether $_POST
Apple < ActiveRecord:Base Orange < ActiveRecord:Base piece_of_fruit = Apple.new I want to know whether
Im creating an application and i want to know whether or not the browser
I want to know whether 301 redirect always preserve referrer. I make a page
I want to know whether it is possible to commit to a previous version.
I am not concerned about other kinds of attacks. Just want to know whether
I don't care what the differences are. I just want to know whether the
I want to know, at run time, whether I'm running on 32 bit or
I'm using ASP.NET MVC Validation. I want to know in my javascript functions whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.