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

Lens: LensTimer::_start might have a wrong implementation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P5
    • 8
    • None
    • javafx

    Description

      Found it while browsing the code - need further testing and investigation

      1. the _start function receive a runnable as an argument, but the timer will always run with the runnable that it was created with.
      2. The _Start method always return 1 as a pointer to the timer - should return a hash value or the reference of the object itself, so timers can be distinguished. Need to check if more then one timer can be created in runtime.
      3. generic comment - the javadoc states that this implementation should provide high resolution timer (i.e hardware timer), but LensTimer is implemented with java timers. Other platforms do use native timers. Need to check if this important, when the timer used and for what.

      Code snippet:
      @Override protected long _start(final Runnable runnable, int period) {
              if (timer == null) {
                  timer = new java.util.Timer(true);
              }

              timer.schedule(task, 0, (long)period); //->> should used if runnable == null, otherwise should use timer.schedule(runnable, 0, (long)period)
              return 1; // need something non-zero to denote success.
          }

      Attachments

        Activity

          People

            ayavnai Assaf Yavnai (Inactive)
            ayavnai Assaf Yavnai (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: