本文整理汇总了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;
}
}
}
}