The previous two examples showed a simple way to execute code outside of the EDT, simply put they spawn a new Thread. The problem with this approach is that creating new threads is an expensive operation, also you shouldn't need to create a new thread if the code is already being executed outside of the EDT.

The `doOutside{}` method takes these concerns into account, spawning a new thread if and only if the code is currently being executed inside the EDT. A rewrite of the previous example would be thus

    class MyController {
        def model    def action1 = {
            // will be invoked inside the EDT by default (pre 0.9.2)
            def value = model.value
            doOutside {
                // do some calculations
                doLater {
                    // back inside the EDT
                    model.result = …
                }
            }
        }    def action2 = {
            // will be invoked outside of the EDT by default (post 0.9.2)
            def value = model.value
            // do some calculations
            doLater {
                // back inside the EDT
                model.result = …
                doOutside {
                    // do more calculations
                }
            }
        }
    }