Does code run in or on a thread?

Any programmers around? Which of the following is correct, or more common:

  • The code runs in a background thread.
  • The code runs on a background thread.

That's it. Just a simple word different.

As an alternative, the code might also be executed in/on a thread, if that makes a difference.


Solution 1:

In a thread (but on a server or an OS), in my experience as a programmer.

Solution 2:

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".