Code example for ReadWriteLock

Methods: readLock, writeLock

0
//vvv everybody else is doing this 
@SuppressWarnings("serial") 
public class ProxyConfig implements java.io.Serializable{
    //This rwlock controls access to the file in which proxy configuration is stored. 
    private static ReadWriteLock configFileLock = new ReentrantReadWriteLock();
    private static Lock configReadLock = configFileLock.readLock();
    private static Lock configWriteLock = configFileLock.writeLock();    
     
    /* 
     * Sets the mode of the proxy server: -HOSTNAMEORMIMETYPE means a request must match have 
     * matches on the hostname AND MIMEType whitelists -HOSTNAMEANDMIMETYPE means a request must 
     * match have matches on the hostname OR MIMEType whitelists -HOSTNAME means a request must 
     * match have a match on the hostname whitelist alone -MIMETYPE means a request must match have 
     * a match on the MIMEType whitelist alone 
     */ 
    public enum Mode { 
        HOSTNAMEORMIMETYPE ("Hostname OR MIMEType"),
        HOSTNAMEANDMIMETYPE ("Hostname AND MIMEType"),
        HOSTNAME ("Hostname only"),
        MIMETYPE ("MIMEType only");