码迷,mamicode.com
首页 > 编程语言 > 详细

Java高性能线程库:Jetlang

时间:2015-11-02 12:29:29      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

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();

项目主页:http://www.open-open.com/lib/view/home/1360159040111

Java高性能线程库:Jetlang

标签:

原文地址:http://my.oschina.net/u/2350108/blog/524741

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!