📄 semaphore.java
字号:
// FrontEnd Plus for JAD
// DeCompiled : semaphore.class
package utils;
public class semaphore
//模拟信号量
{
private boolean inuse;//使用标志
private String description;//信号量的描述
public synchronized void finished()
//完成,有信号
{
inuse = false;
notify();//使用完成
}
public synchronized void use()
//未完成,无信号
throws InterruptedException
{
if(inuse)//正在使用中,必须等待完成
try
{
wait();//等待
}
catch(InterruptedException _ex)
{
throw new InterruptedException(description + " interrupted");
}
inuse = true;
}
public semaphore(String s)
{
description = s;
inuse = false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -