a slide summarizing concurrency changes in java 1.5
w classes and enhancements
Executors, Thread Pools, and Futures
• Concurrent collections: Queues, Blocking
Queues, ConcurrentHashMap
• Locks and Conditions
• Synchronizers: Semaphores, Barriers, etc.
• Atomic Variables
Low-level compare-and-set operation
• Other enhancements
Nanosecond-granularity timing
------------------
class WebServer {
Executor pool =
Executors.newFixedThreadPool(7);
public static void main(String[] args) {
ServerSocket socket = new ServerSocket(80);
while (true) {
final Socket connection = socket.accept();
Runnable r = new Runnable() {
public void run() {
handleRequest(connection);
}
};
pool.execute(r);
}
}
No comments:
Post a Comment