commonlib
threadex.h File Reference

ThreadEx is an abstract class that enables creation of separate threads of execution in an application. More...

#include "threading.h"
#include <thread>
#include <atomic>
#include <mutex>
#include "threadexceptionadapter.h"

Go to the source code of this file.

Classes

class  ThreadEx
 ThreadEx class for working with threads. More...
 

Enumerations

enum  ThreadExPriority : int {
  idle = 0, lowest = 1, low = 2, normal = 3,
  high = 4, highest = 5, timeCritical = 6
}
 

Detailed Description

ThreadEx is an abstract class that enables creation of separate threads of execution in an application.

Author
Tomaž Kos
Date
16/01/2018
Version
1.0

DESCRIPTION

Create a descendant of ThreadEx to represent an execution thread in a multi-threaded application. Each new instance of a TThread descendant is a new thread of execution. Multiple instances of a TThread derived class make an application multi-threaded.

Following are issues and recommendations to be aware of when using threads:

  • Keeping track of too many threads consumes CPU time
  • When multiple threads update the same resources, they must be synchronized to avoid conflicts.
  • Most methods that access an object and update a form must only be called from within the main thread or use a synchronization object.

Define the thread object's Execute method by inserting the code that should execute when the thread is executed.