我需要编写一个模拟餐厅餐 table 的线程。 table 有四个座位。顾客随机来访,如果他们 找到一个空座位他们就留下来,否则他们就离开。 你能帮我么? 谢谢
最佳答案
这是一些伪代码:
-- A Table Thread
integer num_free_seats := 4
loop forever
wait for customer c
if num_free_seats > 0
seat_customer(c)
num_freeSeats := num_free_seats - 1
else
throw_out_customer(c)
end if
关于Linux线程——模拟餐厅餐 table ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5966747/