自己解决了
import java.util.concurrent.Callable
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.Future
fun foo(bar: (m: String) -> String, m: String): Callable{
class CallableLoginJob : Callable {
override fun call(): String {
return bar(m)
}
}
return CallableLoginJob()
}
// my function to pass into the other
fun buz(m: String): String {
println("another message: $m")
return "another message: $m"
}
fun zub(m: String): String {
println("yet another message: $m")
return "yet another message: $m"
}
fun main(){
// someone passing buz into foo
val callableBuz = foo(::buz,"hi" )
val callableZub = foo(::zub,"hi" )
val service: ExecutorService = Executors.newFixedThreadPool(1)
var task: Future = service.submit(callableBuz)
task.get()
task = service.submit(callableZub)
task.get()
service.shutdownNow()
}