Package java.util.concurrent

Examples of java.util.concurrent.ConcurrentLinkedQueue


        try {
            final PackageBuilder packageBuilder = new PackageBuilder();
            packageBuilder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MultithreadFiringCheck.drl" ) ) );
            final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
            ruleBase.addPackage( packageBuilder.getPackage() );
            final Queue errorList = new ConcurrentLinkedQueue();
            final Thread t[] = new Thread[50];
            for ( int i = 0; i < t.length; i++ ) {
                final int count = i;
                t[i] = new Thread( new Runnable() {
                    public void run() {
                        try {
                            final int iterations = count * 15 + 3000;
                            final List results = new ArrayList();
                            final StatefulSession session2 = ruleBase.newStatefulSession();
                            session2.setGlobal( "results",
                                                results );
                            session2.insert( new Integer( -1 ) );
                            for ( int k = 0; k < iterations; k++ ) {
                                session2.insert( new Integer( k ) );
                                if ( k + 1 != session2.getAgenda().agendaSize() ) {
                                    errorList.add( "THREAD-" + count + " ERROR: expected agenda size=" + (k + 1) + " but was " + session2.getAgenda().agendaSize() );
                                }
                            }
                            session2.fireAllRules();
                            session2.dispose();
                            if ( results.size() != iterations ) {
                                errorList.add( "THREAD-" + count + " ERROR: expected fire count=" + iterations + " but was " + results.size() );
                            }
                        } catch ( Exception e ) {
                            errorList.add( "THREAD-" + count + " EXCEPTION: " + e.getMessage() );
                            e.printStackTrace();
                        }
                    }
                } );
                t[i].start();
            }
            for ( int i = 0; i < t.length; i++ ) {
                t[i].join();
            }
            assertTrue( "Errors during execution: " + errorList.toString(),
                        errorList.isEmpty() );
        } catch ( Exception e ) {
            e.printStackTrace();
            fail( "No exception should have been raised: "+e.getMessage());
        }
    }
View Full Code Here


        this.networkNode = networkNode;
        this.linkedSegmentMask = new AtomicBitwiseLong();
    }

    public void initQueue() {
        this.queue = new ConcurrentLinkedQueue();
    }
View Full Code Here

{
    private Collection executors;
    private volatile CircularIterator iterator;

    public CompositeFunctionServer(RequestExecutor[] executors) {
        this.executors = new ConcurrentLinkedQueue(Arrays.asList(executors));
        this.iterator = new CircularIterator(this.executors);
    }
View Full Code Here

            partitionThreads[operationThreadId] = partitionThread;
            partitionThread.start();
        }

        int coreSize = Runtime.getRuntime().availableProcessors();
        this.globalExecutorPriorityQueue = new ConcurrentLinkedQueue();
        this.globalExecutor = executionService.register(ExecutionService.OPERATION_EXECUTOR,
                coreSize * 2, coreSize * 100000, ExecutorType.CONCRETE);
    }
View Full Code Here

     */
    private void runTasks(Thread currentRunninghread) {
        do {
            try {
                Runnable task;
                ConcurrentLinkedQueue tasks = m_tasks;

                while ((task = (Runnable) tasks.poll()) != null) {
                    runTask(task);
                }
            }
            finally {
                m_runningThread.set(null);
View Full Code Here

    /**
     * PERF:
     * Init the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.
     */
    public static Queue initCalendarCache() {
        Queue calendarCache = new ConcurrentLinkedQueue();
        for (int index = 0; index < 10; index++) {
            calendarCache.add(Calendar.getInstance());
        }
        return calendarCache;
    }
View Full Code Here

    private          SegmentMemory   segmentMemory;
    private          Queue           queue;

    public PathMemory(NetworkNode networkNode) {
        this.networkNode = networkNode;
        this.queue = new ConcurrentLinkedQueue();
    }
View Full Code Here

                     "end";
        int N = 1100;

        KnowledgeBase kb = loadKnowledgeBaseFromString( drl );
        final StatefulKnowledgeSession ks = kb.newStatefulKnowledgeSession();
        ConcurrentLinkedQueue list = new ConcurrentLinkedQueue<Integer>();
        AtomicInteger counter = new AtomicInteger(0);
        ks.setGlobal( "list", list );
        //ks.setGlobal( "counter", counter );

        new Thread () {
            public void run () {
                ks.fireUntilHalt();
            }
        }.start ();

        for ( int j = 0; j < N; j++ ) {
            ks.getEntryPoint( "x" ).insert( new Integer( j ) );
        }

        int count = 0;
        while ( list.size() != N && count++ != 1000) {
            Thread.sleep( 200 );
        }

        ks.halt();
        if ( list.size() != N ) {
            for ( int j = 0; j < N; j++ ) {
                if ( !list.contains( new Integer( j ) ) ) {
                    System.out.println( "missed: " + j );
                }
            }
        }

        assertEquals( N, list.size() );
    }
View Full Code Here

    private ConcurrentLinkedQueue<HUDEvent> eventQueue;
    private boolean notifying = false;
    private int id;

    public HUDObject2D() {
        listeners = new ConcurrentLinkedQueue();
        eventQueue = new ConcurrentLinkedQueue();
        bounds = new Rectangle2D.Double();
        id = new Random().nextInt(10000);
    }
View Full Code Here

        = new ReplicationResponseRepository();   
   
    /** Creates a new instance of ReplicationResponseRepository */
    public ReplicationResponseRepository() {
        _repository = new ConcurrentHashMap();
        _queueForQueues = new ConcurrentLinkedQueue();
        _federatedQueryRepository = new ConcurrentHashMap();
    }  
View Full Code Here

TOP

Related Classes of java.util.concurrent.ConcurrentLinkedQueue

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.