Jetlang PoolFiber Sample
3 answers
The use of PoolFiber and ThreadFiber is almost the same. The only difference is that a thread pool must be initialized and used to create each pool.
// create java thread pool.
ExecutorService pool = Executors.newCachedThreadPool();
//initialize factory with backing pool
PoolFiberFactory fiberFactory = new PoolFiberFactory(pool);
Fiber fiber = fiberFactory.create();
fiber.start();
//use fiber for normal publishing and subscribing.
+5
Mike rettig
source
to share
Here it is on Github.
https://github.com/jetlang/jetlang/blob/readme/src/test/java/org/jetlang/examples/BasicExamples.java
Here's the mvn site http://jetlang.github.io/jetlang/
0
source to share
Better pool than Cache includes the number of CPU cores associated with the JVM:
int availableProcessors = Runtime.getRuntime().availableProcessors();
int threadPoolSize = availableProcessors*2;
ThreadPoolExecutor POOL = new ThreadPoolExecutor(threadPoolSize,
threadPoolSize, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
PoolFiberFactory fiberFactory = new PoolFiberFactory(POOL);
0
source to share