package com.thinker.common.thread.lock.spinLock;

public class TestSpinLock implements Runnable{


	static int num;
	private SpinLock lock;

	public TestSpinLock(SpinLock lock){
		this.lock = lock;
	}
	public SpinLock getLock(){
		return lock;
	}

	@Override
	public void run(){
		this.lock.lock();
		this.lock.lock();
		num ++;
		this.lock.unlock();
		this.lock.unlock();
	}
	public static void main(String[] args) {
		SpinLock lock = new SpinLock();
		for(int i=0;i<10;i++){
			TestSpinLock test = new TestSpinLock(lock);
			new Thread(test).start();	
		}
		try{
			Thread.currentThread().sleep(1000);
		}catch(InterruptedException e){
			e.printStackTrace();
		}finally{
			System.out.println(num);
		}
		
	}
	
}
