这段代码错在哪里 public synchronized int waitForRest() throw InterruptedException问题出在 throw 想抛出异常正确写法为 throws 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //我kao,伙计,太离谱了吧。package test;import java.lang.*;public class Barrier{ private int threads2Wait4; private InterruptedException iex; public Barrier(int nThreads) { threads2Wait4 = nThreads; }// public synchronized int waitForRest() throw InterruptedException public synchronized int waitForRest() throws InterruptedException { int threadNum = --threads2Wait4; if(iex!= null) throw iex;// if(thread2Wait4<=0){ if(threads2Wait4<=0){ notifyAll(); return threadNum; } while(threads2Wait4 > 0){ if(iex!=null) throw iex; try{ wait(); }catch(InterruptedException ex){ iex = ex; notifyAll(); } } return threadNum; } public synchronized void freeAll() { iex = new InterruptedException("Barrier Released by freeAll"); notifyAll(); }} public synchronized int waitForRest() throws InterruptedException ///这句改一点{ 为什么web.xml不支持taglib子标签 关于异常的疑问 swt组件可以移植到Swing项目中么? js和yui高手进 java数据求和 小弟初学ant,请教高手有关ant的若干问题 关于java的一个问题 新手问题 死定了!!!!!!在线等候你的佳音 求高人指点 jsp用bean连数据库,出现问题 文件操作???
package test;
import java.lang.*;public class Barrier{
private int threads2Wait4;
private InterruptedException iex; public Barrier(int nThreads)
{
threads2Wait4 = nThreads;
}// public synchronized int waitForRest() throw InterruptedException
public synchronized int waitForRest() throws InterruptedException
{
int threadNum = --threads2Wait4; if(iex!= null) throw iex;
// if(thread2Wait4<=0){
if(threads2Wait4<=0){
notifyAll();
return threadNum;
}
while(threads2Wait4 > 0){
if(iex!=null) throw iex;
try{
wait();
}catch(InterruptedException ex){
iex = ex;
notifyAll();
}
}
return threadNum;
} public synchronized void freeAll()
{
iex = new InterruptedException("Barrier Released by freeAll");
notifyAll();
}
}
{