Thread.activeCount() is different in Java and Kotlin

fun main() {


while (Thread.activeCount() > 1) {
Thread.yield()
}

}

When i use Thread.activeCount() in Kotlin project, the result always 2,but in pure Java project, the result is 1.

So? So shouldn’t rely on Thread.activeCount(), any library you use can create random additional Threads.
Thread.yield() is also a method that you shouldn’t use, as it has no defined behaviour.

You probably just want to put all the threads you care about in a list or something an call join() on them?