1

In this video at 12:14 the demonstrator explains control flow problem with Groovy where we don't know the order of executions for the lines 1,2,3,4. The slide is like below. I don't understand why it is said that (2) can happen before or after 3,4. If 2 is a promise then 3 will definitely happen after 2 and 2 will definitely happen before 3. Can someone explain this or provide example where then part happens before the promise is completed?

enter image description here

user207421
  • 305,947
  • 44
  • 307
  • 483
somename
  • 978
  • 11
  • 30
  • I think they are referring to the `f.success(true)` call, not the `Thread.start(...)` call. The `start()` call will happen before 3, but the `success()` may or may not, since you don't know how long it'll take for the thread to start running. – Andreas Sep 05 '17 at 00:00
  • At the risk of betraying my ignorance, that code doesn't look like valid Java to me. – John Bollinger Sep 05 '17 at 00:16
  • Andread ok i see. john it is groovy but JVM can compile it. – somename Sep 05 '17 at 00:19
  • 2
    @D3_GXT_Java The JVM can't compile anything, let alone Groovy code. It can *execute* the resulting *bytecode*, if the Groovy compiler produces it correctly. – user207421 Sep 05 '17 at 00:35

0 Answers0