简体   繁体   English

同时对象调用

[英]Simultaneous Object Calls

If I have shared an object between 2 threads (by passing in a void pointer to the object) what happens if they both try to call (different) methods at the same time? 如果我在2个线程之间共享一个对象(通过传递指向该对象的void指针),如果它们都尝试同时调用(不同的)方法,会发生什么? I'm not worried about the member variables themselves, there's a mutex in place for other reasons that luckily covers that already. 我并不担心成员变量本身,幸运的是,由于其他原因已经有一个互斥锁。 The main function are calling disjoint methods so there's no possibility of overlap that way, but I wasn't sure what the behavior would be if main calls thing.a() while thread calls thing.b() at the same time (or even if they just overlap for that matter). 主要功能是调用不相交的方法,因此不可能重叠,但是我不确定如果主线程同时调用thing.a()而线程同时调用thing.b()会产生什么行为呢?如果它们只是在此问题上重叠)。

没什么特别的事情,每个线程都有自己的堆栈,并且每个调用(即使是对同一个函数的调用)也将具有自己的调用框架以及自己的参数和局部变量集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM