How threads work
A look at threads "under the hood": an examination of some of the details of thread scheduling, and the implications of different scheduling algorithms for Java threads and the methods that control them.
How they work (or rather, how they don't work...) on specific operating systems. Did you know, for example:
- on Linux, setPriority() has no effect pre Java 6, and that even then you need to run as rootand use a special command-line flag?
- on Windows, the implementation of setPriority() changed between Sun's Java 5 and Java 6 implementations?
- on Windows, thread priorities have little effect on threads competing for CPU?
sleep() and yield()
Information on the limitations and behaviour of sleep() under different load, sleep granularity, and bugs in the Windows implementation. And finally, find out what yield() actually does...!
As with all sections of the Javamex site, suggestions are very welcome here for new topics or specific questions you'd like to see answered. Updates and additions will be added periodically. Corrections are also very welcome since, particularly in the case of the some of the threading topics, I have tried to pull together information which is elusive or described in contradictory ways in different sources!