On Friday, April 28, 2017 at 9:18:03 AM UTC+3, hui zhang wrote: > > How let go and c code work Alternately in the same thread with > goroutine(corouting mechanism) > Check the code below. c and go code in one thread they just do work 1 by > 1. > Expected Result > >> Do CWork >> Do GoWork >> Do CWork >> Do GoWork >> Do CWork >> ..... > > > //c code >> void CWork() { >> while(1) { >> --Print Do CWork >> --Coroutine Stop >> --switch to GoWork() >> } >> } >> int main() { >> CWork(); >> } >> //go code >> func GoWork() { >> for { >> --Print Do GoWork >> --Coroutine Stop >> --switch back to CWork() >> } >> } > > > >
Hi, simplest solution: //c code > void CWork() { > --Print Do CWork > } > int main() { > for { > C.CWork() > GoWork() > } > } > > //go code > func GoWork() { > --Print Do GoWork > } Djadala -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.