Package java.util.concurrent

Examples of java.util.concurrent.LinkedBlockingQueue$LBQSpliterator


    /**
     * Create the queue used to hold incoming requests when requestCoreThreadPoolSize threads are busy.
     * Default is an unbounded queue.
     */
    public BlockingQueue newRequestBlockingQueue() {
        return new LinkedBlockingQueue();
    }
View Full Code Here


        _session = session;
        _prefetchHigh = prefetchHigh;
        _prefetchLow = prefetchLow;
        _exclusive = exclusive;
       
        _synchronousQueue = new LinkedBlockingQueue();
        _autoClose = autoClose;
        _browseOnly = browseOnly;

        try
        {
View Full Code Here

      Context ctx = createContext();

      HashSet threads = new HashSet();

      // A chhanel of communication between workers and the test method
      LinkedBlockingQueue testChannel = new LinkedBlockingQueue();

      for (int i = 0; i < SeveralClientsStressTest.NUMBER_OF_PRODUCERS; i++)
      {
         threads.add(new SeveralClientsStressTest.Producer(i, testChannel));
      }

      for (int i = 0; i < SeveralClientsStressTest.NUMBER_OF_CONSUMERS; i++)
      {
         threads.add(new SeveralClientsStressTest.Consumer(i, testChannel));
      }

      for (Iterator iter = threads.iterator(); iter.hasNext();)
      {
         Worker worker = (Worker)iter.next();
         worker.start();
      }

      long timeToFinish = System.currentTimeMillis() + SeveralClientsStressTest.TEST_ALIVE_FOR;

      int numberOfProducers = SeveralClientsStressTest.NUMBER_OF_PRODUCERS;
      int numberOfConsumers = SeveralClientsStressTest.NUMBER_OF_CONSUMERS;

      while (threads.size() > 0)
      {
         SeveralClientsStressTest.InternalMessage msg = (SeveralClientsStressTest.InternalMessage)testChannel.poll(2000,
                                                                                                                   TimeUnit.MILLISECONDS);

         log.info("Produced:" + SeveralClientsStressTest.producedMessages.get() +
                  " and Consumed:" +
                  SeveralClientsStressTest.readMessages.get() +
View Full Code Here

    // END SNIPPET: common

    public void forDocumentationOnly()
    {
        // START SNIPPET: gauge
        final BlockingQueue queue = new LinkedBlockingQueue( 20 );
        // END SNIPPET: gauge
        // START SNIPPET: gauge
        MetricsGaugeFactory gaugeFactory = provider.createFactory( MetricsGaugeFactory.class );
        MetricsGauge<Integer> gauge = gaugeFactory.registerGauge( getClass(), "Sample Gauge", new MetricsGauge<Integer>()
        {
            @Override
            public Integer value()
            {
                return queue.size();
            }
        } );
        // END SNIPPET: gauge

        // START SNIPPET: counter
View Full Code Here

        final int threads = getInt(properties, "threads", 100);

        final int keepAliveTime = (1000 * 60 * 5);

        ThreadPoolExecutor p = new ThreadPoolExecutor(threads, threads, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
        p.setThreadFactory(new ThreadFactory() {
            private volatile int id = 0;

            public Thread newThread(Runnable arg0) {
                Thread thread = new Thread(arg0, name + " " + getNextID());
View Full Code Here

        @Override
        public Thread newThread(Runnable ignore) {
            String threadName = node.getThreadPoolNamePrefix("partition-operation") + threadId;
            //each partition operation thread, has its own workqueues because operations are partition specific and can't
            //be executed by other threads.
            LinkedBlockingQueue workQueue = new LinkedBlockingQueue();
            ConcurrentLinkedQueue priorityWorkQueue = new ConcurrentLinkedQueue();
            OperationThread thread = new OperationThread(threadName, true, threadId, workQueue, priorityWorkQueue);
            threadId++;
            return thread;
        }
View Full Code Here

public class SedaConfigureTest extends ContextTestSupport {

    public void testBlockingQueueConfigured() throws Exception {
        SedaEndpoint endpoint = resolveMandatoryEndpoint("seda:foo?size=2000", SedaEndpoint.class);
        BlockingQueue<Exchange> queue = endpoint.getQueue();
        LinkedBlockingQueue blockingQueue = assertIsInstanceOf(LinkedBlockingQueue.class, queue);
        assertEquals("remainingCapacity", 2000, blockingQueue.remainingCapacity());
    }
View Full Code Here

   public BasicThreadPool(String name, ThreadGroup threadGroup)
   {
      trace = log.isTraceEnabled();
      ThreadFactory factory = new ThreadPoolThreadFactory();

      queue = new LinkedBlockingQueue(1024);

     
      executor = new ThreadPoolExecutor(4, 4, 60, TimeUnit.SECONDS, queue);
      executor.setThreadFactory(factory);
      executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
View Full Code Here

   public void setMaximumQueueSize(int size)
   {
      // Reset the executor work queue
      ArrayList tmp = new ArrayList();
      queue.drainTo(tmp);
      queue = new LinkedBlockingQueue(size);
      queue.addAll(tmp);

      ThreadFactory tf = executor.getThreadFactory();
      RejectedExecutionHandler handler = executor.getRejectedExecutionHandler();
      long keepAlive = executor.getKeepAliveTime(TimeUnit.SECONDS);
View Full Code Here

    public ServicePool(ServerService next, final String name, int threads) {
        this.next = next;

        final int keepAliveTime = (1000 * 60 * 5);

        threadPool = new ThreadPoolExecutor(threads, threads, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
        threadPool.setThreadFactory(new ThreadFactory() {
            private volatile int id = 0;

            public Thread newThread(Runnable arg0) {
                Thread thread = new Thread(arg0, name + " " + getNextID());
View Full Code Here

TOP

Related Classes of java.util.concurrent.LinkedBlockingQueue$LBQSpliterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.