Line | |
---|
1 | package test2; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | import omq.common.broker.Broker; |
---|
7 | |
---|
8 | public class CarThread extends Thread { |
---|
9 | private String name; |
---|
10 | private String tfn; |
---|
11 | private Object lock; |
---|
12 | |
---|
13 | public CarThread(String name, String tfn, Object lock) { |
---|
14 | this.name = name; |
---|
15 | this.tfn = tfn; |
---|
16 | this.lock = lock; |
---|
17 | } |
---|
18 | |
---|
19 | @Override |
---|
20 | public void run() { |
---|
21 | try { |
---|
22 | Car car = (Car) Broker.lookup(name, Car.class); |
---|
23 | car.setHP(1001); |
---|
24 | car.setPlate("California 125"); |
---|
25 | List<Rim> rims = new ArrayList<Rim>(); |
---|
26 | rims.add(new Rim("asdf", 17)); |
---|
27 | rims.add(new Rim("qwer", 21)); |
---|
28 | car.setRims(rims); |
---|
29 | |
---|
30 | Thread.sleep(1000); |
---|
31 | |
---|
32 | System.out.println("HP -> " + car.getHP()); |
---|
33 | System.out.println("Plate -> " + car.getPlate()); |
---|
34 | for (Rim r : car.getRims()) { |
---|
35 | System.out.println("Rim -> " + r.getModel() + ", " + r.getInch()); |
---|
36 | } |
---|
37 | |
---|
38 | Mobile mobile = (Mobile) Broker.lookup(tfn, Mobile.class); |
---|
39 | synchronized (lock) { |
---|
40 | lock.wait(2000); |
---|
41 | List<String> messages = mobile.getMessages(); |
---|
42 | for (String m : messages) { |
---|
43 | System.out.println("Message -> " + m); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | } catch (Exception e) { |
---|
48 | |
---|
49 | } |
---|
50 | } |
---|
51 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.