Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2919

Runner: prevent creation of multiple threads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.5.0
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      If we stop a runner without waiting for the theard to terminate (join_timeout=0, staring it again might create another thread:

      • Start the runner. This runs thread T1: running=true
      • Stop the runner, don't join t1: running=false. T1 might be doing some longer work, therefore doesn't react to the interrupt
      • Start the runner again. As thread was nulled, we create a new runner thread T2 -> we now have 2 threads running. T1 will not terminate if it swallowed the InterruptedException and running is true

      This is a typical A-B-A problem. It could be fixed by using an AtomicInteger variable with states STOPPED (0) -> RUNNING (2) -> STOPPING (1), and atomically moving between states.

      Note that this is currently not a major issue, as runners are typically started when a protocol is started, and stopped when the protocol is stopped. Also, thread interruption works in most cases.

      This JIRA only aims to harden Runner.

              rhn-engineering-bban Bela Ban
              rhn-engineering-bban Bela Ban
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: