avatar
MITBBS 面试题第一题# JobHunting - 待字闺中
z*u
1
一个系统里面有多个线程, 其中一个线程想终止另外一个线程, 该怎么实现?
考古了一下,没有找到讨论;哪个高手能展开说一说,碰到这个问题应该怎么回答
avatar
b*i
2
哪里

【在 z****u 的大作中提到】
: 一个系统里面有多个线程, 其中一个线程想终止另外一个线程, 该怎么实现?
: 考古了一下,没有找到讨论;哪个高手能展开说一说,碰到这个问题应该怎么回答

avatar
C*U
3
可以message pass吧

【在 z****u 的大作中提到】
: 一个系统里面有多个线程, 其中一个线程想终止另外一个线程, 该怎么实现?
: 考古了一下,没有找到讨论;哪个高手能展开说一说,碰到这个问题应该怎么回答

avatar
h*1
4
invoke Systerm call to terminate the other one
avatar
C*U
5
我以为他问的是实现机制

【在 h*****1 的大作中提到】
: invoke Systerm call to terminate the other one
avatar
C*U
6
if you want the first thread invoke system call to terminate the second
thread, I think the first thread need know the thread ID and some other
information.

【在 h*****1 的大作中提到】
: invoke Systerm call to terminate the other one
avatar
l*a
7
Create a global Event, the second thread can wait for the event ,when the
event is being set, it can call its termination code.
the first thread just need to set the Event.

【在 z****u 的大作中提到】
: 一个系统里面有多个线程, 其中一个线程想终止另外一个线程, 该怎么实现?
: 考古了一下,没有找到讨论;哪个高手能展开说一说,碰到这个问题应该怎么回答

avatar
c*g
8
Message Pass
avatar
z*u
9
using some kind of global variable or semaphore?

【在 c*********g 的大作中提到】
: Message Pass
avatar
f*t
10
这题大概是考你知道几种方法。
只要有win系统的thread handle,或者*nix系统的pthread id,就可以通过系统调用结
束指定线程。
message passing也是一种标准做法。
global variable虽然work,但应该不太好。
avatar
z*3
11
可以pthread——kill(pthread_t tid, int signal)
win没有signal机制 可以通过asynchronous procedure call
还可以扯扯直接杀和deferred杀的优劣
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。