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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:49:11+00:00 2026-06-12T11:49:11+00:00

I am using a file as a cache for big data. One thread writes

  • 0

I am using a file as a cache for big data. One thread writes to it sequentially, another thread reads it sequentially.

Can I be sure that all data that has been written (by write()) in one thread can be read() from another thread, assuming a proper "happens-before" relationship in terms of the Java memory model? Is this behavior documented?

In my JDK, FileOutputStream does not override flush(), and OutputStream.flush() is empty. That’s why I’m wondering…

The streams in question are owned exclusively by a class that I have full control of. Each stream is guaranteed to be accesses by one thread only. My tests show that it works as expected, but I’m still wondering if this is guaranteed and documented.

See also this related discussion.

  • 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-06-12T11:49:12+00:00Added an answer on June 12, 2026 at 11:49 am

    Assuming you are using a posix file system, then yes.

    FileInputStream and FileOutputStream on *nix use the read and write system calls internally. The documentation for write says that reads will see the results of past writes,

    After a write() to a regular file has successfully returned:

    Any successful read() from each byte position in the file that was
    modified by that write shall return the data specified by the write()
    for that position until such byte positions are again modified.

    I’m pretty sure ntfs on windows will have the same read() write() guarantees.

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

Sidebar

Related Questions

I am using file cache in symfony to store my data for some time
I've written a cache manifest file for a big XML file I'm reading data
Are there any relevant security issues in using a file cache (i.e. PEAR Cache_Lite)
I have cache static resources of my website using manifest file But when I
If I am using a cache manifest file like so CACHE MANIFEST: #version 1.0
I'm using XDocument to cache a list of files. <file id=20 size=244318208>a file with
I am using mmap call to read from a very big file using simple
i have one php page with request data from other page using JSON i
We are currently using file based cache in a web-server cluster causing Magento having
In our company we combine every Javascript file into one big (around 700kb but

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.