6 Replies Latest reply on Feb 22, 2008 2:26 AM by 807603

    problem of Thread constructors is before "start()"

      desired behaviour:
      prevent starting of a Thread before a critical a instance variable is defined.

      normally this happens in the constructor. however, this is the unchangeable flow control:
      (1) construct the Thread object.
      (2) calculate the critical instance variable.
      (3) start the Thread.

      if the thread starts without knowning the value calculated in step #2, then it cannot do anything useful.

      in my api, i can say "be careful not to start this thread until after invoking:
      *public void setCriticalValue(int x);*

      how can i +force+ a developer that uses this class to assign the critical instance variable a value before starting the thread? i think something like:

      {code}public void run() {
      if(this.criticalValue == null) { return; }
      public void realStart(List x) {
      this.criticalValue = x;
      would confuse the heck out of a developer and is worst solution.