// Path: src/main/java/com/github/mottox/taomp/common/Backoff.java
// public class Backoff {
// 
//     private final int minDelay;
// 
//     private final int maxDelay;
// 
//     private final Random random;
// 
//     private int limit;
// 
//     public Backoff(int minDelay, int maxDelay) {
//         this.minDelay = minDelay;
//         this.maxDelay = maxDelay;
//         this.limit = minDelay;
//         this.random = new Random();
//     }
// 
//     public void backoff() throws InterruptedException {
//         int delay = random.nextInt(limit);
//         limit = Math.min(maxDelay, 2 * limit);
//         Thread.sleep(delay);
//     }
// }


import java.util.concurrent.atomic.AtomicBoolean;
import com.github.mottox.taomp.common.Backoff;
package com.github.mottox.taomp.concurrent.locks;



/**
 * 使用了{@link com.github.mottox.taomp.common.Backoff}的锁。
 */
public class BackoffLock implements SimpleLock {

    private AtomicBoolean state = new AtomicBoolean(false);

    private static final int MIN_DELAY = 50;

    private static final int MAX_DELAY = 80;

    @Override
    public void lock() {
// Path: src/main/java/com/github/mottox/taomp/common/Backoff.java
// public class Backoff {
// 
//     private final int minDelay;
// 
//     private final int maxDelay;
// 
//     private final Random random;
// 
//     private int limit;
// 
//     public Backoff(int minDelay, int maxDelay) {
//         this.minDelay = minDelay;
//         this.maxDelay = maxDelay;
//         this.limit = minDelay;
//         this.random = new Random();
//     }
// 
//     public void backoff() throws InterruptedException {
//         int delay = random.nextInt(limit);
//         limit = Math.min(maxDelay, 2 * limit);
//         Thread.sleep(delay);
//     }
// }


// Path: src/main/java/com/github/mottox/taomp/concurrent/locks/BackoffLock.java
import java.util.concurrent.atomic.AtomicBoolean;
import com.github.mottox.taomp.common.Backoff;

package com.github.mottox.taomp.concurrent.locks;



/**
 * 使用了{@link com.github.mottox.taomp.common.Backoff}的锁。
 */
public class BackoffLock implements SimpleLock {

    private AtomicBoolean state = new AtomicBoolean(false);

    private static final int MIN_DELAY = 50;

    private static final int MAX_DELAY = 80;

    @Override
    public void lock() {
        Backoff backoff = new Backoff(MIN_DELAY, MAX_DELAY);