Difference between Multi and Single Thread

Asked

Viewed 5,437 times

3

In terms of processes, what is the difference between the multi-thread pro single-thread? How the two forms will work with a requisition?

  • 1

    Except I’m wrong Nodejs only works with one thread. Apache does work both ways. Give better information about what you want to know.

  • The difference between them in terms of process. Once I have made the request, how the server handles it in multi and single.

1 answer

3

It has more architectures besides single-thread (ST) and multi-thread (MT). Basically the TS can only handle one request at a time, so the processing of each one cannot be time consuming, nor can it block (for example, waiting for the database). MT, assuming a thread is created by request, can handle multiple requests in parallel, even if they take too long or block.

A ST server can be effective as long as it never blocks. Node.js is asynchronous so as not to block. Any time-consuming processing should be delegated to another process, which can also be done on Node with subprocess.

Another way to address the problem: Apache’s prefork creates a pool of subprocesses, and delegates requests to each subprocess as they arrive. This ensures parallelism and avoids the complexities of MT programming. This can be implemented also on Node but Apache delivers this factory, which makes life easier for the PHP developer for example, because he doesn’t have to worry if he’s blocking.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.