Moving o java forward part 4- JSR 166y: concurrent Package
Was added to his package to facilitate applications which needs scalable processes.
A feature is atomic variable. Variable atomic means that it cannot be divided - it's like the S.O. with any resource (Driver CD, USB) cannot be divided but needs be used in many processes.
|
Picture 1: Simple example with consumer and producer
It's possible to create one Object and this object will be an atomic variable for this uses the interface java.io.Serializable.
|
Picture 2: create atomic variable
In this new version there are more current collections.
|
BlockingDeque ConcurrentMap ConcurrentNavigableMap |
Picture 3: current Collections
In concurrent process and you would like to lock any resources for other Threads - don't use or access during that time - for this, only use the java.util.concurrent.locks.Lock.
The Executor has the main objective of realizing parallel processes and on a big scale. Now it's possible to use three new interfaces(Executor, ExecutorService, ScheduledExecutorService), These interfaces execute in the Thread pool, so the JVM manages parallel processes. Another improvement is Fork/Join, it helps in a better way for multiple processes and how it can be divided in the letter part and the recursive way.
Conclusion:
This article discusses improvements in the concurrent in java 7, the concurrent package.
- Login or register to post comments
- Printer-friendly version
- otaviojava's blog
- 1577 reads





