Is serial queue faster then synchronized block?
I have two ways to achieve thread safety. I have implemented option-1 but, my supervisor wants me to implement option-2.
Option 1:
synchronized fun doSomething(task: Task){
//task.do()
}
Option 2:
fun doSomething(task: Task){
serialQueue.add(task)
}
Which approach is faster and why? And why two versions exist for single purpose?