We need to maintain a global data structure with 3 fields: id, spawn, done, and update with care (e.g. using a lock). When spawn=done, this thread continues working on bar() after cilk_sync. As the thread which initiated cilk_spawn may not be the last to finish, it may not be the one which executes bar().
Why doesn't Thread 0 steal cont: i = 10?