#! /bin/bash

turno=1

function p1(){
    for i in $(seq 1 10); do
	local ddone=$(false)
	while ! [ $ddone ]; do
	   while [ $turno -eq 2 ]; do
	       echo $i
	       ddone=$(true)
	       turno=2
	   done
       done
    done
}

function p2(){
    for i in $(seq 11 20); do
	local ddone=$(false)
	while ! [ $ddone ]; do
	   while [ $turno -eq 1 ]; do
	       echo $i
	       ddone=$(true)
	       turno=1
	   done
       done
    done
}

p1 & p2 &
wait %1 %2