Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-8533

[Broker-J] SelectorThread is not actual thread

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Broker-J
    • Labels:

      Description

      SelectorThread in Broker-J code extends Thread but it should not be used as a thread.
      SelectorThread works as a command parameter (Runnable) that is put in a new thread:

      SelectorThread command = new SelectorThread(scheduler, numberOfSelectors);
      Thread t = new Thread(command);
      

      There has to be exactly one SelectorThread for every NetworkConnectionScheduler, the SelectorThread maintain a common data that are shared among IO-threads from the scheduler thread pool. We can find the following code in the SelectorThread:

      Thread.currentThread().setName(_scheduler.getSelectorThreadName());
      

      If anybody replaced previous code and set the name directly (calling the inherited setName method) then it would be a bug and the name would not be set to the current thread. The code lure a developer in using the methods inherited from Thread, but these methods would not have the expected effect. SelectorThread is not mentioned to be used as a thread and SelectorThread should only implement Runnable interface instead of extending Thread.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lacam Marek Laca
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: