Multithreading - Concurrency packages
The original multithreading support in Java does not provide high-level features such as locks, thread pools, execution managers, etc.
Java intoduced these features in JDK 5 in the form of concurrent utilities in the java.util.concurrent packages.
Following are the features of the concurrency utilities :
1. synchronizers (locks)
2. Executors
3. Concurrent collections
4. Fork/Join framework
Before starting lets take a look at thread groups.
Every thread in Java,including the main thread, belongs to a thread group. A thread group is a group of threads. In addition to threads, thread groups can also contain sub thread groups. The usefulness of this concept is that we can do operations, like setting thread priority, on a bunch of threads together rather than doing that for individual threads.
ThreadGroup comes with following methods to provide utilities :
setMaxPriority() - Any thread added to the thread group will have this priority
setDaemon() - sets all the threads in the group as daemon threads
interrupt() - attempt to stop all threads
and many more.
An example for thread group can be found here
Java intoduced these features in JDK 5 in the form of concurrent utilities in the java.util.concurrent packages.
Following are the features of the concurrency utilities :
1. synchronizers (locks)
2. Executors
3. Concurrent collections
4. Fork/Join framework
Before starting lets take a look at thread groups.
Every thread in Java,including the main thread, belongs to a thread group. A thread group is a group of threads. In addition to threads, thread groups can also contain sub thread groups. The usefulness of this concept is that we can do operations, like setting thread priority, on a bunch of threads together rather than doing that for individual threads.
ThreadGroup comes with following methods to provide utilities :
setMaxPriority() - Any thread added to the thread group will have this priority
setDaemon() - sets all the threads in the group as daemon threads
interrupt() - attempt to stop all threads
and many more.
An example for thread group can be found here
Comments
Post a Comment