A thread can be in one of the following states: New thread . A thread is in this state after it has been created using the Th...
Synchronizing Threads
A program may access the same object from separate concurrent threads. To ensure that only one thread at a time can access an obj...
Infinite Applet Thread Example
If an applet executes a thread that is terminated only when the user closes or stops the applet, then we need to stop the th...
Finite Applet Thread Example
Before describing a threaded applet example, OneToTwenty is an applet that paints the numbers 1 to 20 in the applet window. OneToTwenty impo...
The Runnable Interface
An applet is created by extending the Applet or JApplet class; a class cannot be a subclass of more than one parent class, so we canno...
Thread Priorities
By default, a thread inherits its priority from the program or thread that created it. It is possible to set a thread's ...
Multithreaded Application Example
In Java application, PrintNumbersThread, which includes thread code that simply lists the numbers 1 to 10. The application will have two t...
The Java Thread Class
Java provides the java.lang.Thread class for explicitly creating and controlling threads. To use threads, first create a subclass of...
Java Threads
It is possible in Java for an individual program to simultaneously perform more than one task, or thread . All the programs discussed in thi...
The Collections Class
The java.util.Collections class provides a number of methods that operate on collections (in most cases, lists). We will describe t...
SortedMap Interface
If we wish to maintain a map in ascending key order, we need to use the TreeMap implementation of the Map interface. MapExamp...
Map Interface
A map is a grouping of keys and their corresponding values. A map cannot contain duplicate keys, and each key can have at most...
List Interface
A list is an ordered collection that may include duplicate elements. The user has control over positional placing of elements in a list. The...
Implementing the Comparable Interfa
Suppose we have an Employee class, with attributes employee number, name, and salary. We then create some Employee objects, and then add the...
SortedSet Interface
If we wish to maintain a set in ascending order, we need to use the TreeSet implementation of the SortedSet interface. CollectExample impo...
Set Interface
A Set is a collection that cannot contain duplicate elements. This is identical to the mathematical definition of a set. All the methods in ...
Collections
The Java Collections Framework consists of a number of interfaces and implementations for handling collections and maps. A collection groups...
Applet Security
Because an applet, resident on a Web server, is invoked by a browser on a client machine, most browsers place security restrictions on what ...
Applet Life Cycle Methods
Because applets are run from browsers, they differ from applications in that they do not have a main method. Instead, applets hav...
Swing Applets
The applet described in the previous section was a subclass of java.applet.Applet and as such did not use any Swing features. The...