9.1.3 Outside Calls - Reference Documentation
Authors: Andres Almiray
Version: 1.2.0
9.1.3 Outside Calls
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.ThedoOutside{}
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 thusclass 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 } } } }