Friday, December 5, 2008

New section: using threads in Java

The first articles in this new section look primarily at how to use "raw" threads in Java. As well as the basics such as how to create a thread and stop or interrupt it, the section looks at more advanced threading topics such as:

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.

Thread priorities

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?
See the article for more information.

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...!

Suggestions welcome!


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!

No comments: