Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.ReadWriteLock


public class ReadWriteLockTest extends TestCase {
    Sync rl, wl;

    protected void setUp() throws Exception {
        super.setUp();
        ReadWriteLock l=new ReentrantWriterPreferenceReadWriteLock();
        rl=l.readLock();
        wl=l.writeLock();
    }
View Full Code Here


    /**
     * store the content in a file
     */
    protected void store(File file, byte[] content) {
        ReadWriteLock lock;
        synchronized (this.locks) {
            lock = (ReadWriteLock) this.locks.get(file.getAbsolutePath());
            if ( lock == null ) {
                lock = new FIFOReadWriteLock();
                this.locks.put(file.getAbsolutePath(), lock);
            }
        }
        Sync sync = lock.writeLock();
        try {
            sync.acquire();
            try {
                OutputStream os = new FileOutputStream(file);
                os.write(content);
View Full Code Here

   
    /**
     * Get the content from a file
     */
    protected byte[] get(File file) {
        ReadWriteLock lock;
        synchronized (this.locks) {
            lock = (ReadWriteLock) this.locks.get(file.getAbsolutePath());
            if ( lock == null ) {
                lock = new FIFOReadWriteLock();
                this.locks.put(file.getAbsolutePath(), lock);
            }
        }
        Sync sync = lock.readLock();
        try {
            sync.acquire();
            try {
                String content = IOUtils.deserializeString(file);
                return content.getBytes();
View Full Code Here

    private final ReadWriteLock getReadWriteLock(IPerson person)
    {
        Object key = new Integer(person.getID());

        ReadWriteLock lock = (ReadWriteLock) mLocks.get(key);

        if (null == lock)
        {
            lock = new ReentrantWriterPreferenceReadWriteLock();
View Full Code Here

    /**
     * store the content in a file
     */
    protected void store(File file, byte[] content) {
        ReadWriteLock lock;
        synchronized (this.locks) {
            lock = (ReadWriteLock) this.locks.get(file.getAbsolutePath());
            if ( lock == null ) {
                lock = new FIFOReadWriteLock();
                this.locks.put(file.getAbsolutePath(), lock);
            }
        }
        Sync sync = lock.writeLock();
        try {
            sync.acquire();
            try {
                OutputStream os = new FileOutputStream(file);
                os.write(content);
View Full Code Here

   
    /**
     * Get the content from a file
     */
    protected byte[] get(File file) {
        ReadWriteLock lock;
        synchronized (this.locks) {
            lock = (ReadWriteLock) this.locks.get(file.getAbsolutePath());
            if ( lock == null ) {
                lock = new FIFOReadWriteLock();
                this.locks.put(file.getAbsolutePath(), lock);
            }
        }
        Sync sync = lock.readLock();
        try {
            sync.acquire();
            try {
                String content = IOUtils.deserializeString(file);
                return content.getBytes();
View Full Code Here

    /**
     * store the content in a file
     */
    protected void store(File file, byte[] content) {
        ReadWriteLock lock;
        synchronized (this.locks) {
            lock = (ReadWriteLock) this.locks.get(file.getAbsolutePath());
            if ( lock == null ) {
                lock = new FIFOReadWriteLock();
                this.locks.put(file.getAbsolutePath(), lock);
            }
        }
        Sync sync = lock.writeLock();
        try {
            sync.acquire();
            try {
                OutputStream os = new FileOutputStream(file);
                os.write(content);
View Full Code Here

   
    /**
     * Get the content from a file
     */
    protected byte[] get(File file) {
        ReadWriteLock lock;
        synchronized (this.locks) {
            lock = (ReadWriteLock) this.locks.get(file.getAbsolutePath());
            if ( lock == null ) {
                lock = new FIFOReadWriteLock();
                this.locks.put(file.getAbsolutePath(), lock);
            }
        }
        Sync sync = lock.readLock();
        try {
            sync.acquire();
            try {
                String content = IOUtils.deserializeString(file);
                return content.getBytes();
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.ReadWriteLock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.