KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > lock > LockStrategyReadCommitted


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.lock;
8
9 import java.util.concurrent.locks.Lock JavaDoc;
10
11 /**
12  * Transaction isolation level of READ_COMMITTED. Similar to read/write lock, but writers are not blocked on readers
13  * It prevents dirty read only.
14  * <p> Dirty read allows (t1) write and then (t2) read within two separate threads, all without
15  * transaction commit. </p>
16  *
17  * @author Ben Wang
18  * @version $Revision: 1.2 $
19  */

20 public class LockStrategyReadCommitted implements LockStrategy
21 {
22    private NonBlockingWriterLock lock_;
23
24    public LockStrategyReadCommitted()
25    {
26       lock_ = new NonBlockingWriterLock();
27    }
28
29    /**
30     * @see org.jboss.cache.lock.LockStrategy#readLock()
31     */

32    public Lock JavaDoc readLock()
33    {
34       return lock_.readLock();
35    }
36
37    /**
38     * @see org.jboss.cache.lock.LockStrategy#upgradeLockAttempt(long)
39     */

40    public Lock JavaDoc upgradeLockAttempt(long msecs) throws UpgradeException
41    {
42       return lock_.upgradeLockAttempt(msecs);
43    }
44
45    /**
46     * @see org.jboss.cache.lock.LockStrategy#writeLock()
47     */

48    public Lock JavaDoc writeLock()
49    {
50       return lock_.writeLock();
51    }
52 }
53
Popular Tags