InvokeLater Freezes the GUI
===

I'm trying to simulate a simple thermostat, using multi-threading. The thermostat should increase the temperature in order to reach the value that the user requested for which is "Max" value in the code below. I have two thread, one in charge of increasing the temperature and the other for decreasing it. but the condition for decreasing is it should be only running when the gas is off. but I have a problem with implementing this concept. 
each time I press the Up button in order to increase the desired temperature the GUI freezes. How can I solve this problem?



    <pre><code>`private void btnUpActionPerformed(java.awt.event.ActionEvent evt) {                                      
        if(Max<=8)
        {
            Max++;
            String strI = String.valueOf(Max);
            lblDesiredTemp.setText(strI);
            
             SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                setGasBoilerStatus();
             }
             });
        }
    }                                     

    private void btnDownActionPerformed(java.awt.event.ActionEvent evt) {                                        
        if(Max>0)
        {
            Max--;
            String strI = String.valueOf(Max);
            lblDesiredTemp.setText(strI);
            
             SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                setGasBoilerStatus();
             }
             });
        }
    }                                       

    private void formWindowActivated(java.awt.event.WindowEvent evt) {                                     
    systemInitial();
    
    tempUp = new temperatureUp();
    tempDown = new temperatureDown();
    
    tempUp.start();
    tempDown.start();
    }                                    
    
    private synchronized void increaseTemeture() throws InterruptedException
    {
        while (!getBoilerStatus()) 
            wait();
        
        Max = Integer.parseInt(lblDesiredTemp.getText());
        Current = Integer.parseInt(lblCurrentTemp.getText());
        
        if(Max>Current)
        {
            lblGasStatus.setText("On");
            lblTemperatureSensor.setText("increasing");
            Thread.sleep(4000);
            Current ++;
            lblPumpStatus.setText("On");
            lblCurrentTemp.setText(String.valueOf(Current));
            txtLog.setText("Temperature increased to " + Current + "\n"+ txtLog.getText());
            if(Current>8)
                lblDanger.setVisible(true);
        }
        
        setGasBoilerStatus();
        
        if(!isGasOn)
        {
        try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                //Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }
            lblGasStatus.setText("Off");
            if(Current != 0)
                lblTemperatureSensor.setText("decreasing");
            else
                lblTemperatureSensor.setText("----");
        }
    }
    
    private synchronized void decreaseTemeture() throws InterruptedException
    {
        while(getBoilerStatus())    wait();
        
        Thread.sleep(4000);
        if(Current == 0 )
            return;
        
        Current --;
        lblCurrentTemp.setText(String.valueOf(Current));
        lblDanger.setVisible(false);
        txtLog.setText("Temperature decreased to " + Current + "\n"+ txtLog.getText());
        if(Current<1)
            lblPumpStatus.setText("Off");
        else
            lblPumpStatus.setText("On");
        
        setGasBoilerStatus();
        
    }
    
    private void systemInitial()
    {
        lblDanger.setVisible(false);
        isPilotOn.setSelected(true);
        lblGasStatus.setText("Off");
        lblPumpStatus.setText("Off");
        isDone = true;
        isGasOn = false;
        Max = Current = 0;
    }
    
    // update the bolier's status to on (true) or off (false)
    public void setBoilerSatus(boolean status) {
            this.isBoilerOn = status;            
    }

    // returns true if the boiler is on, false otherwise
    public boolean getBoilerStatus() {
            return this.isBoilerOn;           
    }

    private synchronized void setGasBoilerStatus() {
        if(Max>Current)
            setBoilerSatus(true);
        else
            setBoilerSatus(false);
        
        notifyAll();
    }

    
    class temperatureUp extends Thread 
    {
        @Override
        public void run()
        {
        while(true)
        {
                try
                {
                    increaseTemeture();                    
                }
                catch(Exception ex)
                {
                    StringWriter w = new StringWriter();
                    ex.printStackTrace(new PrintWriter(w));
                    txtLog.setText(w + "\n" + txtLog.getText());
                }
        }
        }
    };
    
    class temperatureDown extends Thread
    {
        @Override
        public void run() 
        {
            while(true)
            {
                try
                {
                    decreaseTemeture();                    
                }
                catch(Exception ex)
                {
                    StringWriter w = new StringWriter();
                    ex.printStackTrace(new PrintWriter(w));
                    txtLog.setText(w + "\n" + txtLog.getText());
                }
            }
        }
    };
    `

