mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix bug
This commit is contained in:
parent
df58ad5eff
commit
7c4c6c7af1
@ -24,6 +24,7 @@
|
||||
|
||||
### Bug修复
|
||||
* 【core 】 修复SimpleCache死锁问题(issue#I1HOKB@Gitee)
|
||||
* 【core 】 修复SemaphoreRunnable释放问题(issue#I1HLQQ@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,5 @@ public class ThreadUtilTest {
|
||||
final boolean isValid = true;
|
||||
|
||||
ThreadUtil.execute(() -> Assert.assertTrue(isValid));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user