Easy to Start, Tough to Master

Chapter 2 - A Simple Two-Thread Example

Java Thread Programming
Paul Hyde
  Copyright 1999 Sams Publishing

Chapter 2: A Simple Two-Thread Example
Overview
This chapter shows just how simple it is to get a new thread up and running in a tiny Java application. The first thread is the main thread that is always spawned by the Java Virtual Machine (JavaVM) and starts an application. This main thread then spawns the second thread. Each of these threads will print its messages to the console to demonstrate that they both appear to be running simultaneously .
The steps to spawn a new thread in this chapters example are
  Extend the java.lang.Thread class.
  Override the run() method in this subclass of Thread .
  Create an instance of this new class.
  Invoke the start() method on the instance.

Toc


Java Thread Programming
Java Thread Programming
ISBN: 0672315858
EAN: 2147483647
Year: 2005
Pages: 149
Authors: Paul Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net