你会如何做/写这个家庭作业? (理论)
我并不是要求任何人为我做这项作业,但我提出它是因为它是对 C# 和线程的非常好的实用介绍,但同时我觉得它可能有点太简单了。
这真的是教授线程的最佳方法吗? 在此练习中“丢失”了哪些关键的线程概念,第一次使用线程的新程序员可能无法观察到什么?
我有很多关于线程的理论知识,但自己不必做很多事情过去,有人在写的时候对我有什么注意事项吗?
,这是目标文本:
1) 创建线程安全泛型 循环队列类并创建 GUI 使用它(参见下一节)。 在这个 上下文,线程安全意味着每个 改变的操作(方法) 队列的内容应该是 一次仅由一个线程执行 以避免数据损坏。 A 循环队列被实现为 固定大小数组的开头位置 和队列末尾是索引 数组。 当队列填满时, 队列的开头和结尾将 随着元素的变化而转移到更高的值 添加并最终环绕到 数组中要重用的第一个索引 记忆。 这门课还应该 抛出异常(如下指定) 如果操作是调用者 无效的。
2) 创建GUI来控制 生产者-消费者中的两个线程 时尚。 GUI 将能够启动 并启动和停止生产者 和消费者线程并控制 他们修改的速度 通用循环队列。
I'm not asking for anyone to do this homework for me, but I bring it up because it's a very good practical introduction to C# and threading, but at the same time I feel it's perhaps a little too simple.
Is this really the best way to teach threading? what key threading concepts are "lost" in this exercize, what would new programmers using threads for the first time likely fail to observe?
I have alot of theoretical knowledge about threading but haven't had to do alot of it myself in the past, does anyone have any caveats for me when writing it?
Here's the link to the original assignment
and here is the goals text:
1) Create a thread-safe generic
circular queue class and create a GUI
to use it (See next section). In this
context, thread safe means that each
operation (method) that changes the
contents of the queue should be
executed by only one thread at a time
in order to avoid data corruption. A
circular queue is implemented as a
fixed size array where the beginning
and end of the queue are indices in
the array. As the queue fills up, the
beginning and end of the queue will
shift to higher values as elements are
added and eventually wrap around to
the first index in the array to reuse
the memory. This class should also
throw an exception (specified below)
to the caller if the operation is
invalid.2) Create a GUI to control
two threads in a producer-consumer
fashion. The GUI will be able to begin
and start and stop both the producer
and consumer threads and control the
rate at which they modify the
GenericCircularQueue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读此内容:
第二个链接大部分可以独立存在。
Read this:
The 2nd link can mostly stand on it's own.
阅读有关 SyncLock 或 Monitor 的信息(假定为 Windows C#)。
这是理解多线程的好方法,尤其是在多核时代。
Read about SyncLock or Monitor assuming Windows C#.
It as good a way as any to understand multi-threading, especially in the day of multi-cores.
我想说这忽略了两件大事:
I'd say that this misses two big things: