Last change
on this file since 271 was 271, checked in by Tim Baarslag, 5 years ago |
Immutable Chip and Stack
|
File size:
898 bytes
|
Rev | Line | |
---|
[269] | 1 | package onetomany.bargainingchipsgame.players;
|
---|
| 2 |
|
---|
| 3 | import java.util.concurrent.BlockingQueue;
|
---|
| 4 |
|
---|
| 5 | import onetomany.bargainingchipsgame.Bundle;
|
---|
| 6 | import onetomany.bargainingchipsgame.interactions.Offer;
|
---|
[270] | 7 | import onetomany.bargainingchipsgame.interactions.SampleOffer;
|
---|
[269] | 8 |
|
---|
| 9 | public class BilateralAgent implements Runnable
|
---|
| 10 | {
|
---|
| 11 | BlockingQueue<Offer> in;
|
---|
| 12 | BlockingQueue<Offer> out;
|
---|
| 13 |
|
---|
| 14 | public BilateralAgent(BlockingQueue<Offer> in, BlockingQueue<Offer> out)
|
---|
| 15 | {
|
---|
| 16 | super();
|
---|
| 17 | this.in = in;
|
---|
| 18 | this.out = out;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | @Override
|
---|
| 24 | public void run()
|
---|
| 25 | {
|
---|
| 26 | while (true)
|
---|
| 27 | {
|
---|
| 28 | Offer o;
|
---|
| 29 | try {
|
---|
| 30 | o = in.take();
|
---|
| 31 | Bundle bundle = o.getBundle();
|
---|
| 32 | System.out.println("Received " + bundle);
|
---|
[270] | 33 | out.put(new SampleOffer(10));
|
---|
| 34 | System.out.println("Sent " + out);
|
---|
[269] | 35 | } catch (InterruptedException e) {
|
---|
| 36 | // TODO Auto-generated catch block
|
---|
| 37 | e.printStackTrace();
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.