Java Reference
In-Depth Information
int[] args , then you will be required to pass an array, not use a variable-length argument
list.
The objects can be of any type; see the file lang/VarArgsDemo.java for examples of other
types, and argument lists with other arguments before the varargs in the method declaration.
Java 1.5 API Changes
This section lists some of the changes made to Java with the Java 5 (JDK 1.5) release.
Java 5 threading: Concurrency utilities
Java was the first mainstream language with explicit support for multithreading. It has al-
ways been possible to write Java applications that run multiple sections of code more or less
concurrently. In fact, even the simplest Java application creates at least one thread—Java's
memory allocation garbage collection runs in a background thread, started by the Java
runtime before you can say “Hello World.”
However, the code required has sometimes been slightly convoluted. In Java 1.5, the API has
been significantly expanded to provide a series of utility classes that make it much easier to
support multithreaded applications. Even such complex operations as various types of lock-
ing, and creation of thread pools, have been addressed. This work is an outgrowth of an open
source library developed by Doug Lea, author of the topic Concurrent Programming in Java
(Addison-Wesley) and a computer science professor at State University of New York in
Oswego, New York. This code was contributed to the Java Community Process where it has
been extensively worked over by a multitasking committee of multithreading experts. The
package java.util.concurrent and its subpackages contain all of the new classes, and
there are quite a few of them.
One of the key differences from traditional Java synchronization is that the new classes
really are concurrent. In other words, while a synchronized class such as Vector or Hasht-
able uses the object's monitor lock to block all but a single thread from running any syn-
chronized method at a time, the new concurrent classes will allow multiple threads to access
them at the same time, yet still provide “thread-safe” access. For example, the new Concur-
rentHashMap class allows an unlimited number of concurrent reading threads and a (set-
table) maximum number of writes. This will generally lead to much better scalability and
faster performance, both of which become important when designing enterprise-scale applic-
ation services. What's also nice about the ConcurrentHashMap is that, because it still imple-
ments the Map interface from java.util , it is a drop-in replacement for the older synchron-
Search WWH ::




Custom Search