object runProcedureExample {
def runProcedure(task: () => Unit): Unit = {
val runnable = new Runnable {
override def run(): Unit = task()
}
val thread = new Thread(runnable)
thread.start()
}
def main(args: Array[String]): Unit = {
// Define a function to pass as a parameter
val say: () => Unit = () => println("abcd")
// Pass the function to the procedure
runProcedure(say)
}
}
/*
run:
abcd
*/