I have a code like,
Routine 1 {
runtime.LockOSThread()
print something
send int to routine 2
runtime.UnlockOSThread
}
Routine 2 {
runtime.LockOSThread()
print something
send int to routine 1
runtime.UnlockOSThread
}
main {
go Routine1
go Routine2
}
I use run time lock-unlock because, I don't want that printing of Routine 1 will mix with Routine 2. However, after execution of above code, it outputs same as without lock-unlock (means printing outputs mixed). Can anybody help me why this thing happening and how to force this for happening.
NB: I give an example of print something, however there are lots of printing and sending events.