What are threading issues?

We can discuss some of the issues to consider in designing multithreaded programs. These issued are as follows −

The fork() and exec() system calls

The fork() is used to create a duplicate process. The meaning of the fork() and exec() system calls change in a multithreaded program.

If one thread in a program which calls fork(), does the new process duplicate all threads, or is the new process single-threaded? If we take, some UNIX systems have chosen to have two versions of fork(), one that duplicates all threads and another that duplicates only the thread that invoked the fork() system call.

If a thread calls the exec() system call, the program specified in the parameter to exec() will replace the entire process which includes all threads.

Signal Handling

Generally, signal is used in UNIX systems to notify a process that a particular event has occurred. A signal received either synchronously or asynchronously, based on the source of and the reason for the event being signalled.

All signals, whether synchronous or asynchronous, follow the same pattern as given below −

  • A signal is generated by the occurrence of a particular event.

  • The signal is delivered to a process.

  • Once delivered, the signal must be handled.


Thread cancellation is the task of terminating a thread before it has completed.

For example − If multiple database threads are concurrently searching through a database and one thread returns the result the remaining threads might be cancelled.

A target thread is a thread that is to be cancelled, cancellation of target thread may occur in two different scenarios −

  • Asynchronous cancellation − One thread immediately terminates the target thread.

  • Deferred cancellation − The target thread periodically checks whether it should terminate, allowing it an opportunity to terminate itself in an ordinary fashion.

Thread polls

Multithreading in a web server, whenever the server receives a request it creates a separate thread to service the request.

Some of the problems that arise in creating a thread are as follows −

  • The amount of time required to create the thread prior to serving the request together with the fact that this thread will be discarded once it has completed its work.

  • If all concurrent requests are allowed to be serviced in a new thread, there is no bound on the number of threads concurrently active in the system.

  • Unlimited thread could exhaust system resources like CPU time or memory.

A thread pool is to create a number of threads at process start-up and place them into a pool, where they sit and wait for work.

Updated on: 30-Nov-2021

22K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started