Linux线程——模拟餐厅餐 table

标签 linux

我需要编写一个模拟餐厅餐 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/

相关文章:

linux - 用于从文件创建数组并在 curl URL 上使用每个值的 Bash 脚本

linux - 如何让 cron 每 "N"分钟运行一次,其中 n % 5 == 1?

c++ - 无法在特定磁盘上进行 ioctl

c - 在 Linux 中读取和写入相同文件描述符的问题

c++ - 可变参数模板 : iterate over type/template argument

linux - 在 Windows 中访问 QNX 文件系统

linux - 如果您失去 Internet 连接,在服务器上运行的命令会发生什么情况?

linux - 如何重新映射 key : to go in vim command-line mode?

linux - openCV库GLIBC编译错误

c++ - 有没有类似conio.h的库?