import jdk.jfr.Event;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.Random;

public class Test {

    static class FillEvent extends Event {
        String message;
        int value;
        int id;
    }
    
    public static void sendEvent(Random r, int j) {
         FillEvent f = new FillEvent();
         // f.message = (j % 2 == 0) ? "hello, hello, hello, hello, hello!" : "hi!";
         f.message = "hi!";
         f.value = r.nextInt(10000);
         f.id = j;
         f.commit();
    }
    
    public static void runExecutor(ExecutorService executor) throws Exception {
        try {
            for (int i = 0; i < 10; i++) {
                executor.submit(() -> {
                    Random r = new Random();
                    for (int j = 1; j < 500_000; j++) {
                        sendEvent(r, j);
                    }
                });
            }
        } finally {
            executor.shutdown();
            executor.awaitTermination(1, TimeUnit.DAYS);
        }
    }

    public static void main(String[] args) throws Exception {
        ExecutorService executor = Executors.newFixedThreadPool(10);
        runExecutor(executor);
    }
}
