Hello everybody,
I want to create two threads with of priority difference. Fortunately there is a parameter in the function thread which allow to handler the priority with 1 = priority max and 10 = priority min.
This is my code :
import kotlin.concurrent.thread
val t2 = thread(start = false, priority = 10){
println("running from thread(): ${Thread.currentThread()}")
for(i in 1..1000){
println("t2 = $i")
}}
val t1 = thread(start = false, priority = 1){
println("running from thread(): ${Thread.currentThread()}")
for(i in 1..1000){
println("t1 = $i")
}}
fun main(args: Array<String>) {
t1.start()
t2.start()
t1.join()
t2.join()
}
the problem is that there is no priority, we can see on the terminal the value of ‘i’ of t1 and t2 in same time whereas I should see first the value ‘i’ of t1 because it is more priority and then the value ‘i’ of t2
thank you for yours answers