I've a foreground service and i'm executing this method:
Controller().threadTest()
Controller().threadTest()
And my Controller class is:
class Controller{
fun threadTest(){
Thread(Runnable{
threadOperation()
}).start()
}
@Synchronized
private fun threadOperation(){
println("Thread start")
Thread.sleep(3000)
println("Thread finish")
}
}
But the @Synchronized isn't working, because my log is:
Thread start
Thread start
Thread finish
Thread finish
What i'm doing wrong?