由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 面试题
相关主题
Two programming questions...这个用stack实现queue
thread-safe blockingqueue求救: 打印binary tree
share 面试题如何用JAVA中的circular array of queue 解决Josephus problem? (转载)
一道很难的面试题问个题:get max value from Queue, with O(1)?
贡献一道湾区小公司的面试题 MedalliaA家电面
question 2: o(1) euque and dequeue?thread safe blocking queue问题
请教一个系统设计问题 (转载)Java Blocking Queue问题
如何实现binary tree的从下到上的分层打印?这个Java blocking queue实现是不是有问题?
相关话题的讨论汇总
话题: using话题: queue话题: dequeue话题: enqueue话题: thread
进入JobHunting版参与讨论
1 (共1页)
L*****n
发帖数: 15
1
"Implement a circular queue of integers of user-specified size using a
simple array. Provide routines to initialize(), enqueue() and dequeue() the
queue. Make it thread safe."
 
Using c++
怎么写比较好?多谢!
j*****o
发帖数: 394
2
用一个数组的话
用指针记录头和尾的位置
enqueue这么加:  arr[ (tail++)%size ] = val
如果是dequeue 就是HEAD指针“右移”  (也要用 %size).
弱问thread safe是啥概念。。不越界就行啦?

the

【在 L*****n 的大作中提到】
: "Implement a circular queue of integers of user-specified size using a
: simple array. Provide routines to initialize(), enqueue() and dequeue() the
: queue. Make it thread safe."
:  
: Using c++
: 怎么写比较好?多谢!

x*******6
发帖数: 262
3
c++不懂,java可以把那两个方法synchronized
L*****n
发帖数: 15
4
多谢!我也不清楚thread safe 用到这个题是什么意思。同问。

【在 j*****o 的大作中提到】
: 用一个数组的话
: 用指针记录头和尾的位置
: enqueue这么加:  arr[ (tail++)%size ] = val
: 如果是dequeue 就是HEAD指针“右移”  (也要用 %size).
: 弱问thread safe是啥概念。。不越界就行啦?
:
: the

a***o
发帖数: 1182
5
多线程,用lock

the

【在 L*****n 的大作中提到】
: "Implement a circular queue of integers of user-specified size using a
: simple array. Provide routines to initialize(), enqueue() and dequeue() the
: queue. Make it thread safe."
:  
: Using c++
: 怎么写比较好?多谢!

L*****n
发帖数: 15
6
多谢!我还是不太明白多线程lock的用法。麻烦您写一下好吗?我们大家都好学习下。
非常感谢!

【在 a***o 的大作中提到】
: 多线程,用lock
:
: the

j********e
发帖数: 1192
7
他说的估计是用mutex之类的,linux下用pthread_mutex

【在 L*****n 的大作中提到】
: 多谢!我还是不太明白多线程lock的用法。麻烦您写一下好吗?我们大家都好学习下。
: 非常感谢!

1 (共1页)
进入JobHunting版参与讨论
相关主题
这个Java blocking queue实现是不是有问题?贡献一道湾区小公司的面试题 Medallia
再问一个blockingqueue的问题question 2: o(1) euque and dequeue?
一道面试题请教一个系统设计问题 (转载)
F家电面如何实现binary tree的从下到上的分层打印?
Two programming questions...这个用stack实现queue
thread-safe blockingqueue求救: 打印binary tree
share 面试题如何用JAVA中的circular array of queue 解决Josephus problem? (转载)
一道很难的面试题问个题:get max value from Queue, with O(1)?
相关话题的讨论汇总
话题: using话题: queue话题: dequeue话题: enqueue话题: thread