线程等待:
public void run() {
while(true) {
while(conditionIsNotMet)
wait( );
}
}
business method:
public void myBusinessMethod(Object o) {
if(o==null) {
throw new IllegalArgumentException("null argument");
}
//do other things.
}
枚举类型:
public class OmState {
private int state;
private String desc;
public static final OmState SAVE = new OmState(0, "保存");
public static final OmState SUBMIT = new OmState(1, "提交");
public static final OmState SUBMITFAILD = new OmState(2, "未通过");
public static final OmState SUBMITED = new OmState(3, "审批通过");
public static final OmState IMPL=new OmState(5,"实施");
public static final OmState TEST=new OmState(5,"测试");
public static final OmState CHECKED=new OmState(5,"验收通过");
public static final OmState CHECKEDFAILD=new OmState(5,"验收未通过");
public static final OmState INTERUPT=new OmState(5,"中断");
public static final OmState OVER=new OmState(5,"结束");
private static Map INSTANCE = new HashMap();
static {
INSTANCE.put(SAVE.toString(), SAVE);
INSTANCE.put(SUBMIT.toString(), SUBMIT);
INSTANCE.put(SUBMITFAILD.toString(),SUBMITFAILD);
INSTANCE.put(SUBMITED.toString(),SUBMITED);
INSTANCE.put(IMPL.toString(), IMPL);
INSTANCE.put(TEST.toString(), TEST);
INSTANCE.put(CHECKED.toString(), CHECKED);
INSTANCE.put(CHECKEDFAILD.toString(), CHECKEDFAILD);
INSTANCE.put(INTERUPT.toString(), INTERUPT);
INSTANCE.put(OVER.toString(), OVER);
}
public String getDesc() {
return desc;
}
public int getState() {
return state;
}
private OmState(int state, String desc) {
this.state = state;
this.desc = desc;
}
public String toString() {
return Integer.toString(state);
}
public static OmState getInstance(int i) {
return (OmState) INSTANCE.get(Integer.toString(i));
}
}