Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

15. Networking and Threads: Make a Conne... > Java has multiple threads but only o...

Java has multiple threads but only one Thread class

We can talk about thread with a lower-case ‘t’ and Thread with a capital ‘T’. When you see thread, we’re talking about a separate thread of execution. In other words, a separate call stack. When you see Thread, think of the Java naming convention. What, in Java, starts with a capital letter? Classes and interfaces. In this case, Thread is a class in the java.lang package. A Thread object represents a thread of execution; you’ll create an instance of class Thread each time you want to start up a new thread of execution.

image with no caption

A thread (lower-case ‘t’) is a separate thread of execution. That means a separate call stack. Every Java application starts up a main thread—the thread that puts the main() method on the bottom of the stack. The JVM is responsible for starting the main thread (and other threads, as it chooses, including the garbage collection thread). As a programmer, you can write code to start other threads of your own.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint