Print Thread Name and Time

/*
 * This Kotlin source file was generated by the Gradle 'init' task.
 */
package gt.kotlin.sandbox

import java.text.SimpleDateFormat
import java.util.*

class App {
    val greeting: String
        get() {
            return "Hello World!"
        }
}

class ThreadUtils {
    companion object {
        private var lastTime: Long = System.currentTimeMillis()

        fun printWithThreadInfo(msg: String) {
            val thread = Thread.currentThread()
            val threadName = thread.name
            val threadId = thread.id
            val timestamp = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(Date())
            val currentTime = System.currentTimeMillis()
            val elapsedMillis = currentTime - lastTime
            println("[$timestamp][$threadName-$threadId][${elapsedMillis}ms] $msg")
            lastTime = currentTime
        }

        fun sleep(millis: Long){
            Thread.sleep(millis)
        }
    }
}


fun main() {
    ThreadUtils.printWithThreadInfo("Hello World!")
    ThreadUtils.sleep(200)
    ThreadUtils.printWithThreadInfo("Hello World!")
}