我希望并行执行一些不同的任务,但有一个概念,即如果一个任务已经排队或正在处理,它将不会被重新排队.我已经阅读了一些Java API,并提出了下面的代码,这似乎有效.任何人都可以了解我使用的方法是否是最好的方法.有任何危险(线程安全吗?)或更好的方法吗?代码如下:
import java.util.HashMap;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class TestExecution implements Runnable {
String key1;
String key2;
static HashMap<TestExecution, Future<?>> executions = new HashMap<TestExecution, Future<?>>();
static LinkedBlockingQueue<Runnable> q = new LinkedBlockingQueue<Runnable>();
static ThreadPoolExecutor tpe = new ThreadPoolExecutor(2, 5, 1, TimeUnit.MINUTES, q);
public static void main(String[] args) {
try {
execute(new TestExecution("A", "A"));
execute(new TestExecution("A", "A"));
execute(new TestExecution("B", "B"));
Thread.sleep(8000);
execute(new TestExecution("B", "B"));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
static boolean execute(TestExecution e) { …Run Code Online (Sandbox Code Playgroud) 我们遇到了由此处描述的错误引起的问题:http: //bugs.sun.com/view_bug.do?video_id = 6183404
我已经使用自定义字符集实现了修复以修复不正确的映射.但是,这仍然无法解决我们正在使用的一个Java应用程序的问题,因为硬编码使用标准的"GBK"字符集.
有没有办法java.nio.charset.spi.CharsetProvider用来覆盖现有的标准字符集?
尝试编写一个剧本来检查一组文件是否存在于一组服务器(Linux 和 Windows 主机)上,如果存在,则替换这些文件。
这是我到目前为止所拥有的:
---
- hosts: "{{hosts}}"
vars:
scripts:
- check_blackout.pl
- check_empty.pl
tasks:
- name: windows stat
with_items: "{{scripts}}"
win_stat: path=D:\scripts\{{item}}
register: windows_stat
when: "'windows' in group_names"
- name: other stat
with_items: "{{scripts}}"
stat: path=/usr/local/bin/{{item}}
register: other_stat
remote_user: "{{script_owner | default(ansible_user)}}"
when: "'windows' not in group_names"
- name: windows debug
with_items: "{{windows_stat.results}}"
debug: var={{item.item}}
when: "{{item.stat.exists}}"
- name: other debug
with_items: "{{other_stat.results}}"
debug: var={{item.item}}
when: "{{item.stat.exists}}"
...
Run Code Online (Sandbox Code Playgroud)
当我在 Windows 和 Linux 主机上运行此程序进行测试时,我得到以下信息:
[ansible@vmhklftpscdv1 ~]$ ansible-playbook test.yml -e …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个查询,以便从前一个匹配的行构建一些列.例如,使用以下数据:
CREATE TABLE TEST (SEQ NUMBER, LVL NUMBER, DESCR VARCHAR2(10));
INSERT INTO TEST VALUES (1, 1, 'ONE');
INSERT INTO TEST VALUES (2, 2, 'TWO1');
INSERT INTO TEST VALUES (3, 2, 'TWO2');
INSERT INTO TEST VALUES (4, 3, 'THREE1');
INSERT INTO TEST VALUES (5, 2, 'TWO3');
INSERT INTO TEST VALUES (6, 3, 'THREE2');
COMMIT
Run Code Online (Sandbox Code Playgroud)
我想要检索以下数据.
SEQ L1 L2 L3
1 ONE NULL NULL
2 ONE TWO1 NULL
3 ONE TWO2 NULL
4 ONE TWO2 THREE1
5 ONE TWO3 THREE1
5 ONE …Run Code Online (Sandbox Code Playgroud)