Does code run in or on a thread?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puddle Jumping Looping
--
Chapters
00:00 Does Code Run In Or On A Thread?
00:28 Accepted Answer Score 21
00:39 Answer 2 Score 6
01:15 Answer 3 Score 5
02:07 Thank you
--
Full question
https://english.stackexchange.com/questi...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#wordchoice #prepositions #computing
#avk47
ACCEPTED ANSWER
Score 21
In a thread (but on a server or an OS), in my experience as a programmer.
ANSWER 2
Score 6
I've heard/read both being used pretty much interchangeably. If you want to make a distinction, maybe look at how the code you're describing is being run.
Example 1: Given two paths of execution (two threads), and one routine is always run on the secondary thread, one might say that routine is run "on the thread".
Example 2: Given one primary thread, and a subroutine which starts its own thread to run asynchronously, then it might be said to run "in the thread".
ANSWER 3
Score 5
Use "on the thread" to mean that a thread (usually named) is going to carry out a task. For example, events can be dispatched "on the Event thread." One might also say that "graphics rendering occurs on the UI thread." You wouldn't ordinarily refer to code as running "on the thread," but instead used to describe what task runs in that context. This is roughly analogous to running something "on a server."
Use "in the thread" to mean that a thread (possibly unnamed) is running code. Threads are abstract concepts that operate like a box, and on all modern systems, code runs within that context, and are therefore "in the thread." It's usually described in a general way to conceptualize how threads work.
There is usually only one right way to refer to in/on the thread, and you'd have to use the correct context or it might sound odd to professional or experienced developers.