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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:04:07+00:00 2026-05-17T18:04:07+00:00

I have read that code inside a synchronized block conform to ‘happens before’ semantics

  • 0

I have read that code inside a synchronized block conform to ‘happens before’ semantics so that all the values written inside a synchronized block should be visible to other threads in succession. Furthermore I have read that caches are only flushed with the termination of synchronized block. How would above semantic of ‘happens before’ be enforced in the scenario described below if only caches are flushed with the synchronized block termination?

Thread A has a reference to object C and changes a field of C in its synchronized code synchronized on C.
Thread B also has got a reference to object C.
Now thread A is suspended before the synchronized code is finished.
Thread B jumps in to action and access object C’s field in code with no synchronization on C.

Now is thread B guaranteed to see the changes made by Thread A?

  • 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-17T18:04:08+00:00Added an answer on May 17, 2026 at 6:04 pm

    In addition to the existing answer, note that happens-before(X,Y) only guarantees that Y sees updates by X, not that other threads will see results of X before results of Y.

    (In fact, you don’t need to be inside a synchronized block to have happens-before relationships between actions in succession inside a single thread. See the first bullet of 17.4.5 in the JLS.)

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

Sidebar

Related Questions

I have a very large codebase (read: thousands of modules) that has code shared
I have read that using database keys in a URL is a bad thing
I have read that while plug-ins are not supported for SQL Server Management Studio,
I have read that private variables in a base class are technically inherited by
Apparently I can't move files on different volumes using Directory.Move. I have read that
Everything I have read says that when making a managed stored procedure, to right
I have read a lot that LISP can redefine syntax on the fly, presumably
I have a read query that I execute within a transaction so that I
I have read on Stack Overflow some people that have converting to C#2.0 to
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can

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.