문제

I have a vector storing String objects. I want to put a check on vector which must ensure that if new element is added an interrupt is called. How can i write interrupt service routine (If possible) in JAVA?

도움이 되었습니까?

해결책

a simple solution is to make a wrapper for your vector :

class MyVector {
  private Vector;

  public setVector(Vector v){
    this.vector = v;
  }

  public add(String s){
    intruptService();
    vector.add(s);
  }

  private intruptService(){
     //TODO
     your-code
  }

}

other more complicated solution is using Observer Pattern.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top