All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javalite.async.pooltest.HelloPerformanceCommand Maven / Gradle / Ivy

There is a newer version: 2.3
Show newest version
package org.javalite.async.pooltest;

import org.javalite.async.Command;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Igor Polevoy on 4/5/15.
 */
public class HelloPerformanceCommand extends Command {

    private static AtomicInteger counter = new AtomicInteger(0);
    private String message;

    public static long START;

    public HelloPerformanceCommand(String message) {
        this.message = message;
    }

    public HelloPerformanceCommand() {
    } //necessary to provide

    public static void reset() {
        counter = new AtomicInteger(0);
    }

    public static int counter() {
        return counter.get();
    }

    @Override
    public void execute() {
        counter.incrementAndGet();
        System.out.println(counter);
        if (counter.get() == TestSend.MESSAGES_PER_THREAD * TestSend.SENDING_THREAD_COUNT) {
            System.out.println("completed, took " + (System.currentTimeMillis() - START) + " milliseconds");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy