a has to be strictly local to @threads for. Your code seems to make it an existing local variable (see Kristoffer’s comment). Then threads interfere with each other. Make it explicitly local and it runs.
function test()
@threads for i in 1:100
...
local a = d[:a]
...
end
a = [] # ...
end
PS: edited