![JAR search and dependency download from the Maven repository](/logo.png)
jadex.micro.producerconsumer.Main Maven / Gradle / Ivy
The newest version!
package jadex.micro.producerconsumer;
import jadex.core.IComponent;
import jadex.future.FutureBlockingQueue;
/**
* This example shows how a producer consumer pattern can be built with a future based
* blocking queue.
*
* Both sides are balanced by the FutureBlockingQueue.
* producers >> consumers: queue defers enqueue
* consumers >> producers: queue defers dequeue
*
* The future based blocking queue is used as local shared data structure and provides
* protected against concurrent access.
*/
public class Main
{
public static void main(String[] args)
{
int psize = 3;
int csize = 2;
FutureBlockingQueue queue = new FutureBlockingQueue<>(10);
for(int i=0; i(queue, 1000, () -> ""+Math.random()));
for(int i=0; i(queue));
IComponent.waitForLastComponentTerminated();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy