// Path: src/main/java/com/github/mottox/taomp/common/LockCounter.java
// public class LockCounter {
//     private long value;
//     private SimpleLock lock;
// 
//     public LockCounter(SimpleLock lock) {
//         this.lock = lock;
//     }
// 
//     public long get() {
//         // 不想用锁，只是为了暴露取值API。
//         return value;
//     }
// 
//     public long getAndIncrement() {
//         lock.lock();
//         try {
//             long temp = value;
//             value = temp + 1;
//             return temp;
//         } finally {
//             lock.unlock();
//         }
//     }
// }


import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.Assert;
import com.github.mottox.taomp.common.LockCounter;
package com.github.mottox.taomp.concurrent.locks;




/**
 * {@link SimpleLock}测试辅助工具类。
 *
 * @author Robin Wang
 */
public class LockTestHelper {

    public static void testLockAndUnlock(SimpleLock lock) throws Exception {
        // test single thread
        testLockAndUnlock(lock, 1);
        // test multiple threads
        testLockAndUnlock(lock, 4);
    }

    public static void testLockAndUnlock(SimpleLock lock, int thread) throws Exception {
        testLockAndUnlock(lock, thread, 500000);
    }

    public static void testLockAndUnlock(SimpleLock lock, int thread, int iteration) throws Exception {
// Path: src/main/java/com/github/mottox/taomp/common/LockCounter.java
// public class LockCounter {
//     private long value;
//     private SimpleLock lock;
// 
//     public LockCounter(SimpleLock lock) {
//         this.lock = lock;
//     }
// 
//     public long get() {
//         // 不想用锁，只是为了暴露取值API。
//         return value;
//     }
// 
//     public long getAndIncrement() {
//         lock.lock();
//         try {
//             long temp = value;
//             value = temp + 1;
//             return temp;
//         } finally {
//             lock.unlock();
//         }
//     }
// }


// Path: src/test/java/com/github/mottox/taomp/concurrent/locks/LockTestHelper.java
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.Assert;
import com.github.mottox.taomp.common.LockCounter;

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




/**
 * {@link SimpleLock}测试辅助工具类。
 *
 * @author Robin Wang
 */
public class LockTestHelper {

    public static void testLockAndUnlock(SimpleLock lock) throws Exception {
        // test single thread
        testLockAndUnlock(lock, 1);
        // test multiple threads
        testLockAndUnlock(lock, 4);
    }

    public static void testLockAndUnlock(SimpleLock lock, int thread) throws Exception {
        testLockAndUnlock(lock, thread, 500000);
    }

    public static void testLockAndUnlock(SimpleLock lock, int thread, int iteration) throws Exception {
        LockCounter lockCounter = new LockCounter(lock);