Skip to content

Instantly share code, notes, and snippets.

@tarilabs
Created August 3, 2016 08:54
Show Gist options
  • Save tarilabs/7af2ac16f560517d59bc45c0032a7a9f to your computer and use it in GitHub Desktop.
Save tarilabs/7af2ac16f560517d59bc45c0032a7a9f to your computer and use it in GitHub Desktop.
concurrent creation of kiecontainer check
@Test
public void testMATTEO() throws InterruptedException {
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0");
createAndDeployJar( ks, releaseId, createDRL("ruleA") );
ExecutorService es = Executors.newFixedThreadPool(10);
List<Callable<Boolean>> list = new ArrayList<Callable<Boolean>>();
for (int i = 0; i < 6; i++) {
list.add(new Callable<Boolean>() {
@Override
public Boolean call() { ks.newKieContainer("id1", releaseId); return true;}
});
}
List<Future<Boolean>> invokeAll = es.invokeAll(list);
for (Future<Boolean> f : invokeAll) {
try {
System.out.println( f.get() );
} catch (ExecutionException e) {
System.err.println(e.getMessage());
}
}
try {
ks.newKieContainer("id1", releaseId);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment