Hello.
I have a weird problem that happens only wih tomcat 9.0.0-M17+:

- I need to process a parallel java stream inside a custom ForkJoinPool

If I run the code with 9.0.0-M15, I see that all the threads are properly
created using my factory.

If I run the code with 9.0.0-M17+, some of the threads that are used in the
Stream processing are not coming from my factory, but instead are instance
of
org.apache.catalina.startup.SafeForkJoinWorkerThreadFactory$SafeForkJoinWorkerThread.


Sample prototype code:

        ForkJoinPool pool = new ForkJoinPool(2, p -> new
MyForkJoinWorkerThread(p), null, false);
        pool.submit(() -> {
            Stream<T> stream = createMyStream();
            return stream.parallel().map(t -> {
                System.out.println("THREAD: " +
Thread.currentThread().getClass());
                return t;
            }).collect(Collectors.toArrayList());
        }).get();


It seems that something from the newer tomcats "interferes" with the
ForkJoinPool mechanism in some weird way.
Can someone help me to understand what's going on?

thanks,

--fb

Reply via email to