Use volatile to ensure concurrent threads use up to date property value

This commit is contained in:
luccioman 2017-06-15 09:48:22 +02:00
parent 28b451a0b3
commit 5fdd5d16b1

View File

@ -60,19 +60,19 @@ public class Compressor implements BLOB, Iterable<byte[]> {
private TreeMap<byte[], byte[]> buffer;
/** Total size (in bytes) of uncompressed entries in buffer */
private long bufferlength;
private volatile long bufferlength;
/** Maximum {@link #bufferlength} value before compressing and flushing to the backend */
private final long maxbufferlength;
/** Maximum time (in milliseconds) to acquire a synchronization lock on get() and insert() */
private long lockTimeout;
private volatile long lockTimeout;
/** Synchronization lock */
private final ReentrantLock lock;
/** The compression level */
private int compressionLevel;
private volatile int compressionLevel;
/**
* @param backend the backend storage