Java高性能線程庫 Jetlang

openkk 12年前發布 | 23K 次閱讀 Java Java開發

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.
  • Powerful Async Request/Reply Support
  • Single jar with no dependencies except the jdk (1.6+)
  • Integrates with any JVM language - jruby, scala, clojure, groovy, etc
  • Distributed Messaging - Jetlang Remoting
  • </ul> 示例代碼:
    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();</pre>

    項目主頁:http://www.baiduhome.net/lib/view/home/1334063343764

    </strong>

 本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!