本文整理汇总了Java中com.hazelcast.core.IQueue.put方法的典型用法代码示例。如果您正苦于以下问题:Java IQueue.put方法的具体用法?Java IQueue.put怎么用?Java IQueue.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.core.IQueue
的用法示例。
在下文中一共展示了IQueue.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHazelcast
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Bean
public Object testHazelcast(HazelcastInstance inst) throws Exception {
ConcurrentMap aMap = inst.getMap("cz.rkr");
aMap.put("initialValue1", "val1");
aMap.put("initialValue2", "val2");
aMap.put("initialValue3", "val3");
aMap.put("initialValue4", "val4");
aMap.put("initialValue5", "val5");
IQueue<String> queueCustomers = inst.getQueue("cz.eetlite");
queueCustomers.offer("Tom");
queueCustomers.offer("Mary");
queueCustomers.offer("Jane");
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("Second customer: " + queueCustomers.peek());
System.out.println("Second customer: " + queueCustomers.peek());
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("Queue size: " + queueCustomers.size());
queueCustomers.put("TEST");
System.out.println("Queue size: " + queueCustomers.size());
System.out.println("take: " + queueCustomers.take());
System.out.println("Queue size: " + queueCustomers.size());
return aMap;
}
示例2: testPutNull
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Test(expected = NullPointerException.class)
public void testPutNull() throws InterruptedException {
HazelcastClient hClient = getHazelcastClient();
IQueue<?> queue = hClient.getQueue("testPutNull");
queue.put(null);
}