mirror of
https://github.com/corda/corda.git
synced 2025-05-28 13:14:24 +00:00
Give the checkpoint checker thread a meaningful name
This commit is contained in:
parent
a3be4d0dad
commit
71fe0daa08
@ -0,0 +1,19 @@
|
||||
package net.corda.node.utilities
|
||||
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.ThreadFactory
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class NamedThreadFactory(private val name:String, private val underlyingFactory: ThreadFactory) : ThreadFactory{
|
||||
val threadNumber = AtomicInteger(1)
|
||||
override fun newThread(r: Runnable?): Thread {
|
||||
val t = underlyingFactory.newThread(r)
|
||||
t.name = name + "-" + threadNumber.getAndIncrement()
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
fun newNamedSinleThreadExecutor(name: String): ExecutorService {
|
||||
return Executors.newSingleThreadExecutor(NamedThreadFactory(name, Executors.defaultThreadFactory()))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user