Bael 845 transfer queue (#1727)

* BAEL-845 tranferqueue article

* BAEL-845 m to m example

* BAEL-845 move code to test

* BAEL-845 use tryTransfer

* BAEL-845 proper if logic

* BAEL-845 proper test

* BAEL-845 robust test

* BAEL-856 invert logic
This commit is contained in:
Tomasz Lelek 2017-04-25 09:44:59 +02:00 committed by pedja4
parent 6aeb90de5b
commit 1c53e62641

View File

@ -22,11 +22,11 @@ public class Producer implements Runnable {
try { try {
System.out.println("Producer: " + name + " is waiting to transfer..."); System.out.println("Producer: " + name + " is waiting to transfer...");
boolean added = transferQueue.tryTransfer("A" + i, 4000, TimeUnit.MILLISECONDS); boolean added = transferQueue.tryTransfer("A" + i, 4000, TimeUnit.MILLISECONDS);
if (!added) { if (added) {
System.out.println("can not add an element due to the timeout");
} else {
numberOfProducedMessages.incrementAndGet(); numberOfProducedMessages.incrementAndGet();
System.out.println("Producer: " + name + " transferred element: A" + i); System.out.println("Producer: " + name + " transferred element: A" + i);
} else {
System.out.println("can not add an element due to the timeout");
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();