0

I'm trying to visualize what threads are in terms of implementation in memory. I don't have a com-sci background, so I apologize for any fundamental understanding errors (please point out such errors).

My understanding of a process is a 'boxed' area in memory that includes several 'sub'-boxed threads. Here is a helpful SO answer that I've seen: What is the difference between a process and a thread? on this.

I know that a JavaScript process only encompasses a single thread, but that you still have these 'boxed' memory spaces - i.e. an execution context that encapsulates some memory able to access parent scope.

My understanding of, for example, an application context passed to an Android activity, is that it is a 'snapshot' of the process's memory environment (I would imagine ALL the thread and SOME of the process) so that the process can recreate the thread in a new box.

If the above is correct, would it be correct to say that conceptually speaking, a JavaScript execution context and an application context in a threaded language context are comparable in that they both refer to a memory space that is an environment for further work.

Community
  • 1
  • 1
Zach Smith
  • 8,458
  • 13
  • 59
  • 133
  • No, closures are a completely different thing than threads. They are merely a data structure in the memory space, not a box themselves. – Bergi Mar 31 '17 at 13:51
  • Are all `execution context`s in JavaScript implemented by closure? – Zach Smith Mar 31 '17 at 13:56
  • No, an "execution context" is a *stack frame*. I think were confusing that with closures, the "*encapsulat[ion] to access parent scope*". – Bergi Mar 31 '17 at 14:24

0 Answers0