RejectedExecutionException使用ThreadPoolExecutorJava 时最好的处理方法是什么?
我想确保提交的任务不应该被忽视,并且肯定会被执行.截至目前,完成任务还没有艰难的实时要求.
我认为可以完成的事情之一是在循环中等待,直到我知道可运行队列中有空间,然后继续将其添加到队列中.
如果人们可以分享他们的经历会很高兴.
添加可能的解决方案我虽然:
while(executor.getQueue().remainingCapacity <= 0){
// keep looping
Thread.sleep(100);
};
//if the loop exits ,indicates that we have space in the queue hence
//go ahead and add to the queue
executor.execute(new ThreadInstance(params));
Run Code Online (Sandbox Code Playgroud) 我有一个多模块项目,我在父 pom 中使用配置文件,其中提到了特定的依赖项。这里的问题是,如果在子 pom 中,我覆盖了依赖项元素,并提到了父 pom 中的依赖项之一(在父 pom 的配置文件中声明),则该特定依赖项的版本需要是再次提到。
例如父 pom
<dependencies>
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>jobs</artifactId>
<version>4</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>common-dependencies</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>dao</artifactId>
<version>4</version>
</dependency>
</dependencies>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
现在在子 pom.xml
<dependencies>
<!--this one doesnt need a version specified -->
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>jobs</artifactId>
</dependency>
<!--this one makes maven throw an error(if version is not specified) while compilation -->
<dependency>
<groupId>com.mycode.apps</groupId>
<artifactId>dao</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
知道什么可能是错的,我该如何解决这个问题?
注意:配置文件被标记为 activeByDefault
是否可以将命令行参数作为名称值对传递给shell脚本,例如
myscript action=build module=core
Run Code Online (Sandbox Code Playgroud)
然后在我的脚本中,获取变量
$action并处理它?
我知道$ 1 ....等等可以用来获取变量,但是不会像对子那样是名称值.即使它们是,但使用该脚本的开发人员必须负责以相同的顺序声明变量.我不要那个.
广泛的讨论问题.是否有任何库允许我在Java中存储我的应用程序的执行状态?
例如,我有一个处理文件的应用程序,现在应用程序可能会被迫在某个时刻突然关闭.我想存储有关所有文件已处理的内容以及所有文件尚未处理的信息,以及处理的处理阶段正在进行的流程.
是否已有任何抽象此功能的库或我必须从头开始实现它?
我有一个网站,我允许其他开发人员托管内容.我的目标是记录页面上存在的每个超链接(甚至是其他开发人员托管的内容)的点击.
我的初步方法如下:
$('a').click(function(event)
{
//do my logging
return true;
}
);
Run Code Online (Sandbox Code Playgroud)
基本上,问题是,可用的锚标签种类繁多,而且记录点击次数并不那么简单.
许多情况允许我记录我想要的数据,但是在一些情况下,严重破坏了代码.
我知道facebook和谷歌有这个,但他们有一个totol控制,在他们的环境托管什么.
任何帮助是极大的赞赏.
我已经设置了一个带有mod_wsgi,python_sql,mysql和django的Apache服务器.一切正常,除了事实,如果我做了一些代码更改,他们不会立即反映,虽然我认为一切都是动态编译的python/mod_wsgi.
我必须关闭服务器并再次返回以查看更改.
有人能指出我如何通过上述设置实现热部署?
谢谢,
Neeraj
我正在使用一个LogAppender类,它扩展了Console Appender,并在内部使用Sendmail函数发送邮件,如果日志级别为ERROR.(我知道我本可以使用SMPT appender进行邮件发送,但这就是基础设施如何,请避免对此进行任何评论).
我的应用程序分为不同的线程,下面提到的问题偶尔发生.(但有些观察告诉我,这可能是由于一个线程需要更多时间来进行初始化).
我在jstack中得到以下转储:
"pool-68-thread-1":
waiting to lock Monitor@0x0000000005496818 (Object@0xfffffd7e390328b0, a crazycode/api/core/common/log/LogAppender),
which is held by "main"
"main":
waiting to lock Monitor@0x00000000064dbfc0 (Object@0xfffffd7dfb1f8908, a org/apache/log4j/Logger),
which is held by "pool-68-thread-1"
Found a total of 1 deadlock.
Thread t@328: (state = BLOCKED)
- org.apache.log4j.Category.callAppenders(org.apache.log4j.spi.LoggingEvent) @bci=13, line=202 (Interpreted frame)
- org.apache.log4j.Category.forcedLog(java.lang.String, org.apache.log4j.Priority, java.lang.Object, java.lang.Throwable) @bci=14, line=388 (Interpreted frame)
- org.apache.log4j.Category.log(java.lang.String, org.apache.log4j.Priority, java.lang.Object, java.lang.Throwable) @bci=34, line=853 (Compiled frame)
- crazycode.team2Api.common.logging.DESLogger.debug(java.lang.Object) @bci=12, line=240 (Interpreted frame)
- crazycode.api.core.cache.management.CacheFiller.refreshCache(java.util.List, java.lang.Object, java.lang.String) @bci=33, line=229 (Interpreted frame) …Run Code Online (Sandbox Code Playgroud) 我们有一个multiwar项目,并且很多时候有很多人在这个项目上工作,许多未使用的罐子仍然被指定为依赖项,有什么办法可以检查哪些罐子根本没用,但是仍然被引用作为依赖?
我希望maven已经支持这样的事情,考虑到它是如此强大的工具.
我有一个 servlet 过滤器,其中如果调用是 OPTIONS 方法调用,则需要完成一组特定的任务。
有没有一种方法可以检查我的自定义过滤器(到目前为止,它扩展了 javax.servlet.filter),如果传入的 http 请求是 OPTIONS 调用的请求?
谢谢
PS:我使用 jetty 作为我的应用程序服务器。
我做了一些谷歌搜索,直到现在还没有找到一种方法在使用phonegap的设备上使用蓝牙.
我应该看一下其他API的/框架/平台吗?