namespace app { class gui { public : std :: function onButtonClicked ; void setText ( std :: string text ) ; void run ( ) ; } ; class net { public : std :: function onTextReceived ; void sendTextRequest ( ) ; void run ( ) ; } ; } // namespace app int main ( ) { app :: gui gui ; app :: net net ; gui . onButtonClicked = [ & net ] ( ) { // нужно обеспечить безопасность потоков (mutex) net . sendTextRequest ( ) ; } ; net . onTextReceived = [ & gui ] ( std :: string newText ) { // нужно обеспечить безопасность потоков (mutex) gui . setText ( newText ) ; } std :: thread gui_thread { std :: bind_front ( & app :: gui :: run , gui ) } ; std :: thread net_thread { std :: bind_front ( & app :: net :: run , net ) } ; // ждём завершения потоков gui_thread . join ( ) ; net_thread . join ( ) ; }