title: Modify JVM to serialize file access across threads
body: <p>The platform for our application is Java 1.4.2. We need to run certain certification applications on this version of JVM (embedded system).</p>
  
  <p>One of these applications is creating a thread T1 which updates a file (by writing to it) and another thread T2, which is supposed to read the updated contents(T2 is always launched after T1).</p>
  
  <p>The problem is that the writing thread T1 is getting delayed and reading thread T2 is reading incorrect data. The thread T2 doesn't check whether contents of file were updated or not. </p>
  
  <p>The delay causing factor can be assumed to be not fixable for the purposes of this discussion.
  We cannot change the application, but we can change the JVM and the native layer interface.</p>
  
  <p>Please suggest solutions to serialize access to the file <strong>without</strong> changing the application.
  Also, please critique the following approach for feasibility:
  Create a look ahead thread in JVM which can analyze java byte code and serialize access to a file across multiple threads of the same application.</p>