[英]Difference between “call stack” and “task queue”
I'm a developer having difficulties in differentiating between the terms Call Stack and Task Queue . 我是一名开发人员,难以区分术语“ 调用堆栈”和“ 任务队列” 。 Is there anyone who can help me explain the difference?
有谁可以帮助我解释其中的区别?
Thanks in advance. 提前致谢。
eg. 例如。
in JavaScript there is function called timeout. 在JavaScript中,有一个称为超时的函数。 when you call the function timeout on the "call stack" it would register in "job queue".
当您在“调用堆栈”上调用函数超时时,它将在“作业队列”中注册。 It won't fire immediately, but will be triggered once the time is reached.
它不会立即触发,但一旦到达时间就会触发。
timeout(function(){
console.log("one");
}, 100);
console.log("two");
in call stack, console.log("one")
is triggered first, but in job queue, the result will display after two
. 在调用堆栈中,首先触发
console.log("one")
,但在作业队列中,结果将在two
之后显示。
A job queue (sometimes batch queue), is a data structure maintained by job scheduler software containing jobs to run.
作业队列(有时是批处理队列)是由作业调度程序软件维护的数据结构,其中包含要运行的作业。
https://en.wikipedia.org/wiki/Job_queue https://en.wikipedia.org/wiki/Job_queue
A call stack is a stack data structure that stores information about the active subroutines of a computer program.
调用堆栈是一种堆栈数据结构,用于存储有关计算机程序的活动子例程的信息。 This kind of stack is also known as an execution stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack".
这种堆栈也称为执行堆栈,控制堆栈,运行时堆栈或机器堆栈,通常简称为“堆栈”。
https://en.wikipedia.org/wiki/Call_stack https://en.wikipedia.org/wiki/Call_stack
So in short, a job queue is a queue of things to do (usually stored persistant) and a call stack is a stack of routines. 简而言之,作业队列是要做的事情(通常存储的持久性)队列,而调用堆栈是例程的堆栈。
A job would have variables assigned to it, and a call stack would be the abstract implementation. 作业将分配有变量,调用堆栈将是抽象实现。
So a job could "call" a method from a call stack. 因此,作业可以从调用堆栈中“调用”方法。
EDIT: There could be a list of jobs; 编辑:可能会有一份工作清单;
and each job would run a call stack multiple times; 每个作业将多次运行调用堆栈;
First job 第一份工作
Second job: 第二份工作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.