This commit is contained in:
Looly 2020-05-26 15:58:22 +08:00
parent df58ad5eff
commit 7c4c6c7af1
3 changed files with 18 additions and 6 deletions

View File

@ -24,6 +24,7 @@
### Bug修复
* 【core 】 修复SimpleCache死锁问题issue#I1HOKB@Gitee
* 【core 】 修复SemaphoreRunnable释放问题issue#I1HLQQ@Gitee
-------------------------------------------------------------------------------------------------------------

View File

@ -31,16 +31,28 @@ public class SemaphoreRunnable implements Runnable {
this.semaphore = semaphore;
}
/**
* 获得信号量
*
* @return {@link Semaphore}
* @since 5.3.6
*/
public Semaphore getSemaphore(){
return this.semaphore;
}
@Override
public void run() {
if (null != this.semaphore) {
try {
try{
semaphore.acquire();
this.runnable.run();
} catch (InterruptedException e) {
try {
this.runnable.run();
} finally {
semaphore.release();
}
}catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
semaphore.release();
}
}
}

View File

@ -10,6 +10,5 @@ public class ThreadUtilTest {
final boolean isValid = true;
ThreadUtil.execute(() -> Assert.assertTrue(isValid));
}
}