MFC、Qt、C#都是面向对象的编程库
1、MFC不允许跨线程调用对象,即线程只能调用它本身分配了空间的对象
In a multi-threaded application written using MFC, you should not pass MFC objects across thread boundaries. As a general rule, a thread should access only those MFC objects that it creates. Failure to do so may cause run-time problems including assertions or unexpected program behavior
2、Qt不允许跨线程调用对象,同MFC。比如定义一个QObject子类,用于串口通信,那么QSerialPort的new不能放在构造函数里【因为构造函数的代码也是在mian里执行的】,只能放在自定义的槽函数里,由外部信号触发执行。否则会导致在mian里new串口对象,而在线程里调用的情况,这就造成了跨线程调用对象的情况,Qt不允许这样。
3、C#的new只是为对象分配空间,可以跨线程调用