We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Thread

C++11 Multithreading – Part 8: std::future , std::promise and Returning values from Thread

std::promise and std::future

A std::future object can be used with asych, std::packaged_task and std::promise. In this article will mainly focus on using std::future with std::promise object. Many times we encounter a situation where we want a thread to return a result. Advertisements Now question is how to do this? Lets take an example, Frequently Asked: C++11 Multithreading – …

C++11 Multithreading – Part 8: std::future , std::promise and Returning values from ThreadRead More

Designing a Thread Pool Framework Part 1: What’s the need of a Thread Pool

ThreadPool

In this we will discuss what is a Thread pool and why do we need Thread Pools. Many times you encounter a situation where where you need to perform several tasks in parallel to improve the performance of application. These Tasks can be anything like, Advertisements Encrypting a file. Calculating hash of a file. Performing …

Designing a Thread Pool Framework Part 1: What’s the need of a Thread PoolRead More

How to Create a Thread in Java using Runnable Interface

In this article we will discuss how to create a thread in Java using Runnable Interface. Why do we need Runnable Interface We create threads to execute certain tasks in parallel. Every task is different from another Task. Tasks are usually encapsulated in its own class. Therefore, extending our Task class from Thread is not only an incorrect …

How to Create a Thread in Java using Runnable InterfaceRead More

C++11 : Start thread by member function with arguments

In this article we will discuss how to start a thread by a member function of class. Starting thread with non static member function Suppose we have a class Task, which has non static member function execute() i.e. Advertisements class Task { public: void execute(std::string command); }; Now we want to start a thread which …

C++11 : Start thread by member function with argumentsRead More

How to put a thread to sleep in c++11 ? | sleep_for | sleep_until

In this article we will discuss how to put a c++11 thread to sleep. c++11 provides 2 functions for putting a thread to sleep i.e. Advertisements std::this_thread::sleep_for std::this_thread::sleep_untill Sleep for a Duration C++11 provides a function std::this_thread::sleep_for to block the current thread for specified duration i.e. template <class Rep, class Period> void sleep_for (const chrono::duration<Rep,Period>& …

How to put a thread to sleep in c++11 ? | sleep_for | sleep_untilRead More

POSIX : How to create a thread | pthread_create() example & Tutorial

In this article we will discuss how to create a thread in C or C++ using POSIX Thread Library on Linux. Creating a thread will create a separate execution unit with in the same process. Each thread will have its own, Advertisements Stack Thread ID Program counter Thread Local Storage Each of thread shares the …

POSIX : How to create a thread | pthread_create() example & TutorialRead More

POSIX : How to get thread Id of a pthread in Linux | pthread_self() | pthread_equals()

In this article we will discuss how to get thread id of a pthread and compare different thread ids. How to get thread id of current thread Use pthread_self() to get the current thread id i.e. Advertisements #include <pthread.h> pthread_t pthread_self(void); It returns the thread id as pthread_t object for the calling thread. As main function is …

POSIX : How to get thread Id of a pthread in Linux | pthread_self() | pthread_equals()Read More

C++11 : How to get a Thread ID ?

In this article we will discuss how to get thread Id in different scenarios. Every thread has an unique Id associated with it. c++11 provides a type to store this id i.e. Advertisements std::thread::id Objects of std::thread::id is comparable, copy-able and default implementation of std::hash() is also provided by the standard. Therefore, std::thread::id objects can be …

C++11 : How to get a Thread ID ?Read More

C++11: How to create Vector of Thread Objects ?

In this article we will create a vector thread and discuss things which we need to take care while using it. Creating & Using vector of std::thread Let’s Create a vector of std::thread objects i.e. Advertisements // Create a vector of threads std::vector<std::thread> vecOfThreads; Now let’s create a std::function<> object that we will pass to …

C++11: How to create Vector of Thread Objects ?Read More

Cart

Your Cart is Empty

Back To Shop