The std::packaged_task class wraps any Callable objects (function, lambda expression, bind expression, or another function object) so that they can be invoked asynchronously. A packaged_task… Read More
Tag Archives: cpp-multithreading
Given an array arr[] of size N and an integer T representing the count of threads, the task is to find all non-repeating array elements… Read More
Given an input string and a substring. Find the frequency of occurrences of a substring in the given string using pthreads. Examples: Input: string =… Read More
Prerequisites: Socket Programming in C/C++, TCP and UDP server using select, UDP Server-Client implementation in C TCP Client-Server Implementation in C This article describes a… Read More
Odd-Even Transposition Sort is a parallel sorting algorithm. It is based on the Bubble Sort technique, which compares every 2 consecutive numbers in the array… Read More
Prerequisite: C signal handling, IPC through shared memory A signal is used in the UNIX system to notify a process that a particular event has… Read More
Thread::hardware_concurrency is an in-built function in C++ std::thread. It is an observer function which means it observes a state and then returns the corresponding output.… Read More
Thread::joinable is an in-built function in C++ std::thread. It is an observer function which means it observes a state and then returns the corresponding output… Read More
The problem is to synchronize n number of threads using pthread library. The idea is take thread count and print 1 in first thread, print… Read More
Given a 2-D matrix, find the element having maximum value using multi-threading. Prerequisite : Multithreading Examples : Input : {{1, 5, 3, 6}, {22, 10,… Read More
What are conditional wait and signal in multi-threading? Explanation: When you want to sleep a thread, condition variable can be used. In C under Linux, there… Read More
Given a matrix of N x N, task is to find the determinant of the matrix using multi-threading. Examples : Input : mat = {{0,… Read More
Print 1 2 3 infinitely using thread. Create three threads viz T1, T2, and T3 such that those should print 1 2 3 sequence infinitely.… Read More