LINKS

Java Tutor Homepage

Java Applications and Components

Java Applets and Components

Java Frequently Asked Questions:
    1. What is Inheritance?
    2. What is Polymorphism?
    3. What is Encapsulation?
    4. Avoiding the Divide by Zero Error
    5. Public Classes in Java Source Files
    6. The Import Statement in Java
    7. Classes with Default Access
    8. What are Local Variables?
    9. What is an Abstract Method?
    10. Data Structures
    11. What is Autoboxing and Auto-Unboxing?
    12. What is multithreading?
    13. What are Threads?
    14. Thread States
    15. What is the Purpose of Synchronization?
    16. Thread Interaction
    17. Can You Start a Thread Twice?

Java FAQ 13 - What are Threads?

Defining a Thread:

In order to define a thread, you have to have a run() method, there are two ways that you can place a run() method.
1: By extending the Thread class
2: By implementing the Runnable interface

Instantiating a Thread:

Because thread execution begins with an instance of class Thread, you must have a thread object in order to run your thread. There are two ways to do this, which way you should use depends on whether you extending the Thread class, or implementing the Runnable interface.

Starting a Thread:

Starting a thread is very simple:
threadName.start();