From ed1caab0006f6f52513995a7d1c7c6a589aa3582 Mon Sep 17 00:00:00 2001 From: Mariano Barrios Date: Tue, 2 Jun 2015 03:11:53 -0300 Subject: [PATCH] Add example to README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index d976b0c..a09b560 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,22 @@ the queue above capacity. Not being actually a linear queue, this class does not implement the `Collection` or `Queue` interfaces. The traditional queue interface is split in the traits: `Offerable` and `Pollable`. Sub-queues do however implement Collection. +Example +------- + +Sub queues are created from the multi queue: + + LinkedBlockingMultiQueue q = new LinkedBlockingMultiQueue(); + LinkedBlockingMultiQueue.SubQueue sq1 = q.addSubQueue(1 /* key*/, 10 /* priority */); + LinkedBlockingMultiQueue.SubQueue sq2 = q.addSubQueue(2 /* key*/, 10 /* priority */); + +Then it is possible to offer and poll: + + sq1.offer("x1"); + q.poll(); // "x1" + sq2.offer("x2"); + q.poll(); // "x2" + API ---