Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4218741

The Thread class should have methods "when-stopped" and "change-Runnable"

XMLWordPrintable

    • generic
    • generic



      Name: vm36539 Date: 03/09/99


      Hey, Java People.
      When writing concurrent code, it would just make life so much
      easier to have a method called "whenstopped()" or something
      similar in java.lang.Thread java.lang.Runnable that the JVM
      calls when it is finished. This would be REALLY useful when
      writing a ReplicatedWorkers class and I think it would only
      add one line of code to the Java source. The primary purpose
      would be for overriding the method in extended classes (such
      as the Worker class in the Replicated Workers problem...are you
      familiar with this problem: there are several workers and a
      static FIFO workpool. They pick up jobs from the workpool and
      try to pick up another job once they have finished the one they
      had. If they don't have any more jobs in the workpool, they
      add themselves to a worker Queue. Classically, a thread is
      wasted as a "foreman" who monitors the other threads and hands
      out the jobs.) Removal of the foreman thread is what I am trying
      to accomplish and this would be much easier with this method
      built in. So, how about it?

      When I write the code, maybe this sort of class could be built
      in to Java since it really increases performance and without it,
      programs with too many threads will crash quickly (especially
      on supercomputers, I have found...especially convexes). If you
      would be willing to chew on my class, I would be honored to
      sacrifice any ownership of the class short of paying for my own
      use of it :-) (copyrights, etc.)

      One more thing. This is a little harder. Why not stick in a
      method to change a Thread's runnable post-creation and post-run?
      This would also simplify just about everything I do, and I don't
      think it would be too tough to code, but you'd have to stick
      in a few "throws"'s in the method call, I think.

      Thank you so much!
      Java ROCKS!!
      -- Ali Mohammad.
      Computer Scientist/Mathematician/Physicist/Computer Engineer
      @ large.
      (Review ID: 54691)
      ======================================================================

            jjb Josh Bloch
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: