Last active
March 16, 2017 12:04
-
-
Save enesakar/386df73f9a19358b898fa9582dbccdea to your computer and use it in GitHub Desktop.
exec service hazelcast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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