Chapter 3. Creating and Starting a Thread


This chapter explores more of the Thread API, including getting a handle on the currently executing thread, thread naming, some of the different constructors, and putting a thread to sleep for awhile. You will use these features to enhance the TwoThread example from Chapter 2, "A Simple Two-Thread Example."

Using Thread.currentThread()

At times, it's useful to know which of the threads currently running in the Java Virtual Machine (JavaVM) is executing a segment of code. In multithreaded programming, more than one thread may enter a method and ...

Get Java Thread Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.