Skip to content

Instantly share code, notes, and snippets.

@gurbuzali
Created January 31, 2016 09:04
Show Gist options
  • Save gurbuzali/a87bc828404d9a062267 to your computer and use it in GitHub Desktop.
Save gurbuzali/a87bc828404d9a062267 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance();
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
HazelcastInstance instance3 = Hazelcast.newHazelcastInstance();
HazelcastInstance instance4 = Hazelcast.newHazelcastInstance();
IExecutorService exec = instance1.getExecutorService("exec");
exec.submitToAllMembers(new MyCallable());
}
static class MyCallable implements Callable, HazelcastInstanceAware, Serializable {
transient HazelcastInstance instance;
@Override
public Object call() throws Exception {
long threadId = Thread.currentThread().getId();
System.err.println("instance: " + instance.getName() + ", threadId: " + threadId);
return null;
}
@Override
public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
this.instance = hazelcastInstance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment