Java高性能线程库 Jetlang

码农软件 · 软件分类 · 其他开发相关 · 2019-10-31 21:29:03

软件介绍

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.
示例代码:
// start thread backed receiver. 
// Lighweight fibers can also be created using a thread pool
Fiber receiver = new ThreadFiber();
receiver
.start();

// create java.util.concurrent.CountDownLatch to notify when message arrives
final CountDownLatch latch = new CountDownLatch(1);

// create channel to message between threads
Channel<String> channel = new MemoryChannel<String>();
Callback<String> onMsg = new Callback<String>() {
   
public void onMessage(String message) {
       
//open latch
        latch
.countDown();
   
}
};
//add subscription for message on receiver thread
channel
.subscribe(receiver, onMsg);

//publish message to receive thread. the publish method is thread safe.
channel
.publish("Hello");

//wait for receiving thread to receive message
latch
.await(10, TimeUnit.SECONDS);

//shutdown thread
receiver
.dispose();

本文地址:https://codercto.com/soft/d/17994.html

数据科学家养成手册

数据科学家养成手册

高扬 / 电子工业出版社 / 2017-5 / 79

作为认知科学的延伸,数据科学一方面应该越来越引起广大大数据工作者的重视,另一方面也要撩开自己的神秘面纱,以最为亲民的姿态和每位大数据工作者成为亲密无间的战友,为用科学的思维方式进行工作做好理论准备。《数据科学家养成手册》从众多先贤及科学家的轶事讲起,以逐步归纳和递进的脉络总结出科学及数据科学所应关注的要点,然后在生产的各个环节中对这些要点逐一进行讨论与落实,从更高、更广的视角回看科学及数据科学在各......一起来看看 《数据科学家养成手册》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具