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

  • Home
  • SEARCH
  • 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 8191559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:56:46+00:00 2026-06-07T03:56:46+00:00

I have two separate Java processes, a producer and a consumer, that behave as

  • 0

I have two separate Java processes, a producer and a consumer, that behave as follows:

Producer:

write data file
close data file
write hash file
close hash file

Consumer:

wait until hash file exists
read data file
act on data file
close data file
delete data file
delete hash file

The hash file is only used by this code to signal that the data file is complete. The value of the hash is not validated here. Under normal load there should be one handoff every 3 seconds. Under very heavy load, the rate might increase to one handoff every 100 ms. The filesystem is ext3 with data=ordered.

How can I make sure that the consumer never sees an incomplete file?

One option is to verify the contents of the data file against the hash but that seems unnecessarily expensive. I considered using java.nio.channels.FileLock but I am concerned that it won’t remove the need for the hash check because if the producer crashes, the OS frees all its locks even though the file may still be incomplete. This is actually a very likely case for producing an incomplete file. Maybe a lock plus a check that the consumer is still running?

  • 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-07T03:56:47+00:00Added an answer on June 7, 2026 at 3:56 am

    The producer can close the file before starting a new file.

    The consumer can wait for the next file before starting the previous one.

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

Sidebar

Related Questions

I am developing two java programs that run in separate VM's that have a
I have 2 java script functions triggered by two separate buttons. I am trying
I have two separate applications (both part of the same system) that share a
I have two separate sets of tables in the same database that model the
I have 2 separate Java Applications running at a time. (Two separate javaw.exe) I
I have a lookup table that should be accessed by two separate key values.
I have seen the question: Communication between two separate Java desktop applications (answer: JGroups)
I have two separate java maven projects: one is my web app itself and
I have two separate objects in Java, Object1 and Object2 , both are the
Okay, hopefully this is quick and easy. I have two separate java projects, 'Library'

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.