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

(timer) TimerTask should be an interface, or else take an interface as argument

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Won't Fix
    • P4
    • None
    • 1.4.0
    • core-libs

    Description

      Name: jl125535 Date: 09/16/2003


      A DESCRIPTION OF THE REQUEST :
      TimerTask needs an additional constructor, which takes a Runnable as argument.

      At the moment, many people cannot use TimerTask, because java only has single inheritance. It is not possible (in any way) to extend two classes. It is usual in an Object-oriented project to already have to extend another class.

      JUSTIFICATION :
      The problem is that java only allows single inheritance. If I have a class that already MUST extend a superclass, I cannot use TimerTask.

      The change is very small, and uses an interface that already exists in Java, the Runnable interface.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Since Timertask is only being extended to provide an implementation of the run() method, you could enable everyone to use it by this simple method:

      Add an extra constructor to TimerTask that takes a Runnable as argument. (this guarantees that the class has a .run() method EXACTLY as per TimerTask)
      (Incident Review ID: 189484)
      ======================================================================
      ###@###.### 11/1/04 22:54 GMT

      Attachments

        Activity

          People

            martin Martin Buchholz
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: