我确信我可以将一些东西放在一起,这可以让我弄清楚这一点,但我希望有一个我只是缺少的开箱即用的解决方案.我阅读了文档,但我没有看到任何内容.
我的特定应用程序使用的是a ThreadPoolExecutor支持DelayQueue,虽然我不确定这是否重要.
谢谢!
我正在尝试创建一个ThreadPoolExecutor:
// Thingy implements Delayed and Runnable
ExecutorService executor = new ThreadPoolExecutor(1, 1, 0l, TimeUnit.SECONDS, new DelayQueue<Thingy>());
Run Code Online (Sandbox Code Playgroud)
编译器说"找不到符号":
symbol : constructor ThreadPoolExecutor(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.DelayQueue<Thingy>)
Run Code Online (Sandbox Code Playgroud)
但我不明白 - DelayQueue实现BlockingQueue,所以我不能使用这个构造函数?
我想注释一些错误响应,如下所示:
* Response 412
If the Etag supplied in `If-Match` didn’t match.
* Response 428
If the request didn’t include the header `If-Match`.
Run Code Online (Sandbox Code Playgroud)
但解析器(snowcrash)似乎将注释解释为响应主体.
我如何注释这些回复并让snowcrash明白它们是注释?
我知道all并且choice,但他们没有考虑我希望某些元素能够多次出现的情况,例如:
<Root>
<ThingA/>
<ThingB/>
<ThingC/>
<ThingC/>
<ThingC/>
</Root>
Run Code Online (Sandbox Code Playgroud)
我可以使用sequence,但我更愿意让这些孩子处于任何顺序.我可以使用any,但后来我不能超过一个ThingC.我可以使用choice,但我不能限制ThingA和ThingB为0或1.
我想我可能已经读过某些地方,这在XSD中很难或不可能,但RELAX NG也许可能.不幸的是,我不记得我在哪里读到这些.
谢谢你的帮助!
我刚刚在runnable的run()方法中编写了这段代码:
try {
dbConnection = MyApp.datasource.getConnection();
} catch (SQLException e) {
logger.log(Level.SEVERE, "Could not obtain a DB connection! Re-enqueuing this task. Message: " + e.getMessage(), e);
MyApp.executor.execute(this);
return;
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,如果任务无法获得数据库连接,它应该将自身重新入队,并进入运行之前的队列.
我认为这可能是安全的,但感觉很有趣,我只是想确保没有任何我缺少的东西.
谢谢!
executors ×3
java ×3
apiblueprint ×1
concurrency ×1
executor ×1
queueing ×1
schema ×1
task ×1
xml ×1
xsd ×1