The release history of the JSR 166 frame retrospective version of the JSR 166 framework in the java class library
The release history of the JSR 166 frame retrospective version of the JSR 166 framework in the java class library
The JSR 166 is part of concurrent programming in the Java class library. It provides a set of reused classes to simplify the development process of concise concurrent programming.In the JSR 166 framework, the retrospective version refers to a backward library provided by the concurrent function on the old Java platform.
The following is the release history and update log of the JSR 166 framework back retrospective:
1. Java 5:
-It introduced Java.util.Concurrent packages, which contain a large number of classes and interfaces used for concurrent programming, such as Executor frameworks, concurrent collection, atomic variables, etc.
2. Java 6:
-In the release of Java 6 updated the class library provided by the JSR 166, adding a new concurrency collection class, such as the ConcurrentLINKEDEQUE, LinkedTransferqueue, etc.
-Pripped the concurrent blocking queue class linkedBlockingDeque, ArrayBlockingQueue, etc.
-The introduced ThreadPoolexecutor class to manage the thread pool.
-Su new synchronous tools COUNTDOWLATCH, SEMAPHORE, etc.
3. Java 7:
-Accosted the Forkjoin framework to handle parallel calculations for processing division tasks.
-The Phaser class is introduced for thread stage synchronization.
-This provides the TransferQueue interface to support more efficient producers-consumer model.
-Che more concurrent sets, such as ConcurrentskiplistSet, ConcurrentskiplistMap, etc.
-The ThreadLocalrandom class was introduced to generate random numbers.
4. Java 8:
-The CompletableFuture class is introduced for combined asynchronous programming.
-In new method of increasing concurrency, such as ConcurrenThashmap.
-The new time API is introduced, which provides delay and timing functions for concurrent tasks.
The above is the release history and update logs of the JSR 166 framework retrospective version.Through continuous iteration and update, the JSR 166 provides a set of powerful concurrent programming tools, making it easier for developers to write high -efficiency and secure multi -threaded applications.
Here are some examples of Java code in some JSR 166 framework libraries:
1. Executor framework example:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ExecutorExample {
public static void main(String[] args) {
ExecutorService executorService = Executors.newFixedThreadPool(5);
for (int i = 0; i < 10; i++) {
Runnable worker = new WorkerThread("" + i);
executorService.execute(worker);
}
executorService.shutdown();
while (!executorService.isTerminated()) {
}
System.out.println ("All threads are executed");
}
}
class WorkerThread implements Runnable {
private String name;
public WorkerThread(String name) {
this.name = name;
}
@Override
public void run() {
System.out.println (thread.currentthread (). Getname () + "starts the task" + name);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println (thread.currentthread (). Getname () + "completes the task" + name);
}
}
2. Example of concurrent set class:
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
public class ConcurrentCollectionsExample {
public static void main(String[] args) {
ConcurrentHashMap<String, Integer> map = new ConcurrentHashMap<>();
map.put("A", 1);
map.put("B", 2);
map.put("C", 3);
System.out.println("ConcurrentHashMap: " + map);
CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<>();
list.add("A");
list.add("B");
list.add("C");
System.out.println("CopyOnWriteArrayList: " + list);
}
}
The above example shows how the class libraries provided by the JSR 166 framework are programs, including the Executor framework to manage the thread pool, as well as the use class of concurrenThashmap and CopyonWriteArrayList.
It is hoped that this article will help understand the release of the release of the JSR 166 framework, and the use of the concurrent programming tools provided by it.