赞
踩
- package com.cqh.Hazelcast_Queue;
-
- import com.hazelcast.core.Hazelcast;
- import com.hazelcast.core.HazelcastInstance;
-
- import java.util.concurrent.BlockingQueue;
- import java.util.concurrent.TimeUnit;
-
- /**
- * Created by yl1794 on 2018/5/2.
- */
- public class SampleQueue {
- public static void main(String[] args) throws Exception {
- HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
- BlockingQueue<Integer> queue = hazelcastInstance.getQueue( "tasks" );
- queue.put( 111 );
- queue.take();
-
- boolean offered = queue.offer( 222, 10, TimeUnit.SECONDS );
- Integer task = queue.poll( 5, TimeUnit.SECONDS );
- if ( task != null ) {
- //process task
- }
- }
- }

- package com.cqh.Hazelcast_Queue;
-
- import com.hazelcast.core.Hazelcast;
- import com.hazelcast.core.HazelcastIn
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。