bash: assign to an array in bash from a function called with the & control operator
===

I'd like to know why this works:

    arr=()
    fun() { arr[$1]=$2; }
    fun 1 2
    echo ${arr[1]}
    # echoes '2'

but this doesn't:

    arr=()
    fun() { arr[$1]=$2; }
    fun 1 2 &
    wait
    echo ${arr[1]}
    # echoes a blank line