Skip to content

Instantly share code, notes, and snippets.

@gurbuzali
Created February 10, 2014 13:39
Show Gist options
  • Save gurbuzali/8916106 to your computer and use it in GitHub Desktop.
Save gurbuzali/8916106 to your computer and use it in GitHub Desktop.
3.1.5
static void testContainsKey() throws InterruptedException {
final Config config = new Config();
final MapConfig mapConfig = config.getMapConfig("m");
mapConfig.setTimeToLiveSeconds(900);
mapConfig.setNearCacheConfig(new NearCacheConfig().setTimeToLiveSeconds(900));
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
instance1.getMap("m").put("key", "value");
final Thread t = new Thread() {
@Override
public void run() {
final IMap<Object, Object> m = instance2.getMap("m");
while (!Thread.currentThread().isInterrupted()) {
final boolean key = m.containsKey("key");
System.err.println("contains: " + key);
}
}
};
t.start();
Thread.sleep(1000);
instance1.getLifecycleService().terminate();
Thread.sleep(10000);
t.interrupt();
t.join();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment