Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4534

Thread.join appears to not work correctly in at least one special case

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.7.5
    • 1.7.6, 1.8-beta-3
    • None
    • None
    • 32 bit Windows XP, Groovy 1.7.5. Also using Eclipse 3.6 + groovy plugin

    Description

      While writing test code for a networking component I ran into the following issue. I created a thread to read from a socket, started it and then wrote to a client socket. After writing called thread.join() and expected it to finish executing my server socket thread before continuing. Instead what I get is non-deterministic behavior. Sometimes the thread finishes sometimes not. Since the thread isn't doing much if I add a sleep the code works (my work around in my test code). To be clear I'm not expecting that the print statements execute in any particular order - I'm concerned that the lines won't get added to the list and thus the current thread hasn't actually waited for the spawned thread to exit.

      I've attached a sample groovy class that exhibits the problem and the equivalent Java code that does not have the issue.

      Attachments

        1. JoinProblemG.groovy
          1 kB
          Reid Nimz
        2. JoinProblemJ.java
          2 kB
          Reid Nimz
        3. 4534_v17x.diff
          3 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            rnimz Reid Nimz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: