Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top