Sorry for reviving this older thread, but I have the same question. Here’s another similar/same example where julia is started with julia -t 1,1
, and the method “bar” blocks the method “foo”, which is not what I expected. This is with Julia 1.9.3.
function foo()
x = 0
tic = time()
while true
if time() - tic > 30
break
end
println("inside interactive loop, x=$x")
x += 1
sleep(1)
end
end
function bar()
x = 1
c = -1
d = 3
tic = time()
while true
if time() - tic > 30
break
end
x += c/d
c *= -1
d += 2
end
@info "bar, after 30 seconds, pi is $(4*x)"
end
tsk = Threads.@spawn :interactive foo()
bar()
wait(tsk)
output:
[ Info: bar, after 30 seconds, pi is 3.1415926521589954
inside interactive loop, x=0
inside interactive loop, x=1
inside interactive loop, x=2
inside interactive loop, x=3
inside interactive loop, x=4
inside interactive loop, x=5
inside interactive loop, x=6
inside interactive loop, x=7
inside interactive loop, x=8
inside interactive loop, x=9
inside interactive loop, x=10
inside interactive loop, x=11
inside interactive loop, x=12
inside interactive loop, x=13
inside interactive loop, x=14
inside interactive loop, x=15
inside interactive loop, x=16
inside interactive loop, x=17
inside interactive loop, x=18
inside interactive loop, x=19
inside interactive loop, x=20
inside interactive loop, x=21
inside interactive loop, x=22
inside interactive loop, x=23
inside interactive loop, x=24
inside interactive loop, x=25
inside interactive loop, x=26
inside interactive loop, x=27
inside interactive loop, x=28
inside interactive loop, x=29