ru.hnau.jutils.finisher.NewThreadFinisher.kt Maven / Gradle / Ivy
package ru.hnau.jutils.finisher
import kotlin.concurrent.thread
@Deprecated("Use kotlinx.coroutines.Deferred instead")
class NewThreadFinisher(
action: (onFinished: (T) -> Unit) -> Unit
) : Finisher(
{ onFinished -> thread { action.invoke(onFinished) } }
) {
companion object {
fun sync(action: () -> T) =
NewThreadFinisher { onFinished ->
val result = action.invoke()
onFinished.invoke(result)
}
}
}