Skip to content

Instantly share code, notes, and snippets.

@enesakar
Last active March 16, 2017 12:04
Show Gist options
  • Select an option

  • Save enesakar/386df73f9a19358b898fa9582dbccdea to your computer and use it in GitHub Desktop.

Select an option

Save enesakar/386df73f9a19358b898fa9582dbccdea to your computer and use it in GitHub Desktop.
exec service hazelcast
public interface Task<String> extends Callable<String>, Serializable {
String call();
}
public static void main(String[] args) throws InterruptedException, TimeoutException, ExecutionException {
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance();
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
ExecutorService ss = Executors.newFixedThreadPool(1);
final Task task = new Task() {
public Object call() {
System.out.println("print");
return "result";
}
};
System.out.println(ss.submit(new Callable<Future<String>>() {
public Future<String> call() {
final Member member = instance1.getCluster().getLocalMember();
final IExecutorService executor = instance1.getExecutorService("default");
return executor.submitToMember(task, member);
}
}).get().get());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment