#vulnerable code 
                                public Command recv (long timeout_)
    {
        Command cmd_ = null;
        //  Try to get the command straight away.
        if (active) {
            cmd_ = cpipe.read ();
            if (cmd_ != null) {
                
                return cmd_;
            }

            //  If there are no more commands available, switch into passive state.
            active = false;
            signaler.recv ();
        }


        //  Wait for signal from the command sender.
        boolean rc = signaler.wait_event (timeout_);
        if (!rc)
            return null;

        assert (rc);
        //  We've got the signal. Now we can switch into active state.
        active = true;

        //  Get a command.
        cmd_ = cpipe.read ();
        assert (cmd_ != null);
        
        return cmd_;
    } 
                            #location 19 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public Command recv (long timeout_)
    {
        Command cmd_ = null;
        //  Try to get the command straight away.
        if (active) {
            cmd_ = cpipe.read ();
            if (cmd_ != null) {
                
                return cmd_;
            }

            //  If there are no more commands available, switch into passive state.
            active = false;
            signaler.recv ();
        }


        //  Wait for signal from the command sender.
        boolean rc = signaler.wait_event (timeout_);
        if (!rc)
            return null;

        //  We've got the signal. Now we can switch into active state.
        active = true;

        //  Get a command.
        cmd_ = cpipe.read ();
        assert (cmd_ != null);
        
        return cmd_;
    }