乐观锁和悲观锁解决leetcode的1117题目H2O生成问题
使用乐观锁+Thread.yield实现package com.gavin;import org.junit.jupiter.api.Test;import java.util.concurrent.Semaphore;public class LockTest { private static final String strs = "HHOOHHOHOHHH"; private volatile int hNum = 0; @Test public