Discussed in more detail in A different do block scope rule exist for `Threads.lock(my_lock)`?
This is unrelated to JuMP.