/Users/lyon/j4p/src/classUtils/pack/util/pool2/test/PassivableObject.java
|
1 package classUtils.pack.util.pool2.test;
2
3 import java.io.Serializable;
4
5 /**
6 * A simple passivatable object for test purposes.
7 * <p>
8 * Each instances is automatically associated at construction an incremental id,
9 * unique within the JVM.
10 *
11 * @author cris
12 */
13 public class PassivableObject implements Serializable, ObjectWithID {
14
15 private static int c=0;
16 private static Object lock = new Object();
17 private String id;
18
19 public PassivableObject() {
20 synchronized(lock) {
21 id=String.valueOf(c++);
22 }
23 }
24
25 /**
26 * Returns the id.
27 * @return String
28 */
29 public String getId() {
30 return id;
31 }
32
33 /**
34 * @see java.lang.Object#toString()
35 */
36 public String toString() {
37 return "Passivable object #"+id;
38 }
39
40 }
41