本文整理匯總了Java中java.util.Map.notifyAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Map.notifyAll方法的具體用法?Java Map.notifyAll怎麽用?Java Map.notifyAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Map
的用法示例。
在下文中一共展示了Map.notifyAll方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeRequest
import java.util.Map; //導入方法依賴的package包/類
public static HttpResponse executeRequest(HttpRequest p_executeRequest_0_) throws IOException
{
final Map<String, Object> map = new HashMap();
String s = "Response";
String s1 = "Exception";
HttpListener httplistener = new HttpListener()
{
public void finished(HttpRequest p_finished_1_, HttpResponse p_finished_2_)
{
synchronized (map)
{
map.put("Response", p_finished_2_);
map.notifyAll();
}
}
public void failed(HttpRequest p_failed_1_, Exception p_failed_2_)
{
synchronized (map)
{
map.put("Exception", p_failed_2_);
map.notifyAll();
}
}
};
synchronized (map)
{
HttpPipelineRequest httppipelinerequest = new HttpPipelineRequest(p_executeRequest_0_, httplistener);
addRequest(httppipelinerequest);
try
{
map.wait();
}
catch (InterruptedException var10)
{
throw new InterruptedIOException("Interrupted");
}
Exception exception = (Exception)map.get("Exception");
if (exception != null)
{
if (exception instanceof IOException)
{
throw(IOException)exception;
}
else if (exception instanceof RuntimeException)
{
throw(RuntimeException)exception;
}
else
{
throw new RuntimeException(exception.getMessage(), exception);
}
}
else
{
HttpResponse httpresponse = (HttpResponse)map.get("Response");
if (httpresponse == null)
{
throw new IOException("Response is null");
}
else
{
return httpresponse;
}
}
}
}