Nick Widelec wrote:
What's the relation between fairness of locks and fairness of threads?
When set true, under contention, locks favor granting access to the longest-waiting thread.
.
It means that it just suggests a kind of scheduling, however at the end of it it's the system who decides right?
Scheduling applies to runnable threads. The scheduler chooses the next runnable
thread to execute -- based on priority, time since last run, etc. And yes, all current JVM implementations do use the native scheduler to schedule the thread, and hence, it is the system that does the "fairness of threads".
Lock fairness applies to blocked threads -- specifically, the threads that are blocked on the lock. It is the lock that decides which thread to moved into the runnable state, and hence, can be scheduled. The other threads are still blocked, and hence, can't be scheduled.
Henry