try {sleep((int)(Math.random()*50));}
catch(InterruptedException e){;}
System.out.println("Unlocking writeLock:"+getName());
sem.writeUnlock();
}
}
}
public class testSem{
public static void main(String argv[]){
Semaphore lock = new Semaphore();
new Process("1","read",lock);
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/