AbstractQueuedSynchronizer(十)——应用之ReentrantLock

来源:互联网 发布:python web服务 编辑:程序博客网 时间:2024/05/21 13:21

1.AbstractQueuedSynchronizer注释上可以被用作锁的方法(5个)

public interface Lock {    void lock();    void lockInterruptibly() throws InterruptedException;    boolean tryLock();    boolean tryLock(long time, TimeUnit unit) throws InterruptedException;    void unlock();    Condition newCondition();}
public final void acquire(int arg)

This method can be used to implement method {@link Lock#lock}.

public final void acquireInterruptibly(int arg)

This method can be used to implement method {@link Lock#lockInterruptibly}.

public final boolean tryAcquireNanos(int arg, long nanosTimeout) throws InterruptedException 

This method can be used to implement method {@link Lock#tryLock(long, TimeUnit)}.

public final boolean release(int arg) 

This method can be used to implement method {@link Lock#unlock}.

protected boolean tryAcquire(int arg) 

This can be used to implement method {@link Lock#tryLock()}.

0 0
原创粉丝点击