Java高性能線程庫:Jetlang
Jetlang 提供了一個高性能的Java線程庫,該庫是 JDK 1.5 中的 java.util.concurrent 包的補充,可用于基于并發消息機制的應用。該類庫不提供遠程的消息功能,其設計的宗旨是實現一個內存中的消息傳遞機制:
主要特點有:
- All messages to a particular Fiber are delivered sequentially. Components can easily keep state without synchronizing data access or worrying about thread races.
- Single Fiber interface that can be backed by a dedicated thread or a thread pool.
- Supports single or multiple subscribers for messages.
- Subscriptions for single events or event batching
- Single or recurring event scheduling
- High performance design optimized for low latency and high scalability
- Publishing is thread safe, allowing easy integration with other threading models.
- Low Lock Contention – Minimizing lock contention is critical for performance. Other concurrency solutions are limited by a single lock typically on a central thread pool or message queue. Jetlang is optimized for low lock contention. Without a central bottleneck, performance easily scales to the needs of the application.
Fiber fiber = new ThreadFiber(); fiber.start(); final CountDownLatch latch = new CountDownLatch(2); Runnable toRun = new Runnable(){ public void run(){ latch.countDown(); } }; //enqueue runnable for execution fiber.execute(toRun); //repeat to trigger latch a 2nd time fiber.execute(toRun); latch.await(10, TimeUnit.SECONDS); //shutdown thread fiber.dispose();
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!