Why this code doesn’t work (no output)?
clo1 = {
for(int i =0; i<=10; i++){
println(i);
}
}
def thread = Thread.start { clo1 }
But this do work:
def thread = Thread.start {
for(int i =0; i<=10; i++){
println(i);
}
}
If you want to execute
clo1in the thread you can either door
The first one passes the closure directly to
Thread.start. The second solution creates a new closure which executesclo1.With
Thread.start { clo1 }just you pass a new closure (that does nothing) toThread.start.