Class ManagedFile


  • public class ManagedFile
    extends Object
    Defines the notion of a managed file with a classic Read-Write locking policy. A managed file can be locked for multiple concurrent reads or a single write.

    A simple example could follow this :

    ManagedFile managedFile = new ManagedFile(new File(...), 1000, -1); Lock writeLock; try { writeLock = managedFile.writeAccess(); // write or delete the file } finally { writeLock.unlock(); }

    Author:
    Jerome Dochez
    • Constructor Detail

      • ManagedFile

        public ManagedFile​(File file,
                           int timeOut,
                           int maxHoldingTime)
                    throws IOException
        Creates a new managed file.
        Parameters:
        file - the file to manage
        timeOut - the max time in milliseconds to wait for a read or write lock
        maxHoldingTime - the max time in milliseconds to hold the read or write lock
        Throws:
        IOException - when the file cannot be locked