Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top