62,614
社区成员
发帖
与我相关
我的任务
分享
ExecutorService service = Executors.newFixedThreadPool(1);
try
{
CountDownLatch countDownLatch = new CountDownLatch(1);
// 执行
service.execute(new ApplyCallable(call, logisticsContext, response, countDownLatch));
try
{
if(countDownLatch.await(1, TimeUnit.SECONDS))
{
// 不超时
return response;
}
}
catch (Exception e)
{
// ignore exception
}
// 来到这里表示超时
// throw new TimeoutException("send request timeout");
logger.error("######耗时申请跟踪号######", new String[][]{{"运输方式", transportationMode.getTransportationModeChinese()}});
}
finally
{
service.shutdown();
}
@Override
public void run()
{
try
{
Thread.sleep(5 * 1000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
try
{
System.out.println("====继续进行======");
}
finally
{
countDownLatch.countDown();
}
}
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at com.bessky.pss.portal.business.logistics.util.TrackNumberUtils$ApplyCallable.run(TrackNumberUtils.java:258)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[bessky_it][ERROR][2017-05-17 16:16:02] | PSS | ######耗时申请跟踪号###### | 运输方式=京华达香港平邮(华南快速小包平邮), | com.bessky.pss.portal.business.logistics.util.TrackNumberUtils.applyTrackingNumber(TrackNumberUtils.java:208)
====继续进行======