package com.gh.gamecenter.core

import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger

class GHThreadFactory(threadNamePrefix: String) : ThreadFactory {

    private val THREAD_NAME_STEM = "${threadNamePrefix}_%d"
    private val mThreadId = AtomicInteger(0)

    override fun newThread(r: Runnable?): Thread {
        val t = Thread(r)
        t.name = String.format(THREAD_NAME_STEM, mThreadId.getAndIncrement())
        return t
    }

}