doubleh3lix
Imagine coming to an overcrowded fast food restaurant to order the best taco in the country and there’s only one cook working there. He prepares each taco one by one. Although the cook has an extra time while waiting until a tortilla heats up, he doesn’t start preparing another order until the first one is finished.
想象一下,到一家人满为患的快餐店订购全国最好的炸玉米饼,那里只有一位厨师。 他一步一步地准备每个炸玉米饼。 尽管厨师在等待玉米饼变热之前有额外的时间,但是直到第一个订单完成后,他才开始准备其他订单。
That’s your software without concurrency and parallelism.
那就是您的软件,没有并发性和并行性。
But what are the differences between those two? How are they handled in Elixir? Let’s start from the beginning.
但是两者之间有什么区别? 在Elixir中如何处理? 让我们从头开始。
并发与并行 (Concurrency vs parallelism)
In order to better understand the difference, let’s take a closer look at the above mentioned restaurant problem.
为了更好地理解差异,让我们仔细看一下上述餐厅问题。
Imagine that the cook has just received orders for two tacos. So far, he’s prepared each order separately which is preparing the first taco from the beginning to the end and then the same with the second one. However, he decides to do it at the same time. Steps that he’s taking look as follows:
想象一下,厨师刚刚收到了两份玉米饼的订单。 到目前为止,他已经分别准备了每个订单,这是从头到尾准备第一个炸玉米饼,然后与第二个炸玉米饼相同。 但是,他决定同时进行。 他正在采取的步骤如下所示:
- The cook’s preparing a tortilla for the first order,
厨师的准备饼一阶 ,
- The cook’s preparing a tortilla for the second order,
厨师正在准备第二份玉米饼,
- For the first order, the cook’s putting vegetables and chicken on a tortilla,
对于第一笔订单 , 厨师把蔬菜和鸡肉放在玉米饼上,
- For the second order, the cook’s putting vegetables and chicken on a tortilla,
第二个命令是厨师将蔬菜和鸡肉放在玉米饼上,
- The cook’s putting a taco from the first order into the cooker to heat it up,
厨师的投入塔科从第一顺序放进瓦煲内,以热起来,
- The cook’s putting a taco from the second order into the cooker to heat it up,
厨师将第二份塔可乐中的炸玉米饼放入锅中加热,
- The taco from the first order is ready to serve,
一阶的炸玉米饼随时可用
- The taco from the second order is ready to serve.
来自第二订单的炸玉米饼随时可以使用。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/128630.html