In reply to peterjin:
Because you declared the task receive() with a static lifetime (the implicit default lifetime). That means there is only one argument index for all calls to receive. Change the declaration to
task automatic receive(int index);