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 6110991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:34:46+00:00 2026-05-23T14:34:46+00:00

I am reading the JLS spec on memory model, 17.4.5 Happens-before Order . I

  • 0

I am reading the JLS spec on memory model, 17.4.5 Happens-before Order.
I do not understand the first rule:

“# If x and y are actions of the same thread and x comes before y in program
order, then hb(x, y).”

Let’s assume A an B are objects (instances of class object) that can be shared between multiple threads:

int i=A.getNum();  // ActionA
int j=B.getNum();  // ActionB

Three questions:

  1. According to the above rule, does it mean hb(ActionA,ActionB)?

  2. If the answer to 1 is true, does it mean according to happens-before rule, ActionB can not reordered to come before ActionA in any JVM that follows JSR133 memory model?

  3. If 1 and 2 both are true, it seems that ActionA and ActionB are not relevant, why can not reorder them? just for this spec?

  • 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-23T14:34:46+00:00Added an answer on May 23, 2026 at 2:34 pm

    It is my understanding that:

    1. you’re right
    2. they can be reordered, but only if action B doesn’t depend on result of action A

    Happens-before relationship doesn’t say anything about reordering actions. It only says that if HB(A, B) holds, then action B must see memory effects of action A.

    If action B doesn’t use any result of action A, then there is no reason why they cannot be reordered. (In general, “use any result of another action” is pretty broad, and it can only be detected for quite simple actions, like memory reads/writes, not for actions using external resources like I/O operations, or time-based operations)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading a few threads ( common concurrency problems , volatile keyword , memory model
Reading the Redis documentation on Virtual Memory at: http://redis.io/topics/virtual-memory With regards to vm-max-threads they
I'm reading this: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.20.2 They say: Consider the example program: class Point { int
Reading this: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions What does it mean to add a 'member route'? or do
Reading here: JLS 8.3.1.4 volatile Fields Without volatile it says then method two could
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning
Reading some questions here on SO about conversion operators and constructors got me thinking
Reading among the list of possibilities of the Java ME platform, its possible for
reading the documentation for java org.w3c.dom.ls it seems as a Element only can be
Reading some posts from Jimmy Boggard and wondering - how exactly is it possible

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.