/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.epics.pvmanager.sample;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.epics.pvmanager.PVManager;
import org.epics.pvmanager.PVReader;
import org.epics.pvmanager.PVReaderEvent;
import org.epics.pvmanager.PVReaderListener;
import org.epics.pvmanager.vtype.ExpressionLanguage;
import org.epics.util.time.TimeDuration;
import org.epics.vtype.VType;

/**
 *
 * @author carcassi
 */
public class MultiplePVLoadTest {

    private static List<PVReader<VType>> readers = new ArrayList<>();
    private static final AtomicInteger counter = new AtomicInteger();

    public static void main(String[] args) throws InterruptedException {
        int nPvs = 5000;

        SetupUtil.defaultCASetup();

        for (int i = 0; i < nPvs; i++) {
            PVReader<VType> reader = PVManager.read(ExpressionLanguage.vType("sim://noise"))
                    .readListener(new PVReaderListener<VType>() {
                @Override
                public void pvChanged(PVReaderEvent<VType> event) {
                    counter.incrementAndGet();
                }
            }).maxRate(TimeDuration.ofHertz(50));
            readers.add(reader);
        }

        Thread.sleep(60000);

        for (PVReader<VType> pVReader : readers) {
            pVReader.close();
        }
    }
}

@@ -1,100 +1,121 @@
 /*
+*
 %0D%0A * 
-To change this template, choose Tools %7C Templates%0D%0A * and open the template in the editor
+Copyright (C) 2010-12 Brookhaven National Laboratory%0D%0A * All rights reserved. Use is subject to license terms
 .%0D%0A 

Fix copyright