Coroutine "threads" in Tomee server?


#1

Hi,

If I run this simple code in a JUnit test:

runBlocking {
    async{
        LOGGER.warn("hello")
    }
}

I can see that a lightweight thread is being used:
16:01:53.455 [ForkJoinPool.commonPool-worker-9 @coroutine#2] WARN MyClass - hello

However, exactly the same code run in a WAR file in a Tomee server:

16:01:09.030 [ForkJoinPool.commonPool-worker-9] WARN MyClass - hello

Is there is something I am missing? How can I know whether coroutine “threads” are used or not?

(logback configuration for both):

    <configuration debug="false" reload="true">
        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>%d{HH:mm:ss.SSS} [%thread] %X{travelc.userId} %X{travelc.websessionid} %-5level %logger{50} - %msg%n</pattern>
            </encoder>
        </appender>
        <root level="warn">
            <appender-ref ref="STDOUT" />
        </root>
    </configuration>

#2

@coroutine#2 is added to the thread name when either kotlinx.coroutines.debug system property is set or assertions are enabled. You can read more here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md#debugging-coroutines-and-threads


#3

Thanks, didn’t know that.