ImageGear for C and C++ on Linux v19.10 - Updated
Process PDF Using Multiple Threads
User Guide > How to Work with... > Formats with Additional Functionality > PDF > How to... > Process PDF Using Multiple Threads

In a single-threaded application, the initialization (IG_PDF_initialize()) and termination (IG_PDF_terminate()) functions must be called only once during the life of the application. Attempting to initialize the Adobe PDF Library and DLI more than once in the application may cause errors or unpredictable behavior, and is not supported. You are free to create multiple documents and/or multiple files within the run, but the initialization and termination of the Adobe PDF Library and DLI is limited to one iteration of each.

In a multi-threaded application, you must call IG_PDF_initialize() and IG_PDF_terminate() in the main thread and in each thread that will use the ImageGear PDF Component. The reason is that the first initialization of the Library requires some extra processing that later initializations do not, such as building of font resource lists. By keeping an initialized Library instance open in the parent process, you can improve the initialization time for every child process. Otherwise, if you have a point in the process where no child has the Library open, the next one to initialize will have to do a full startup again.

Thus we strongly recommend, whenever possible, that you initialize the Adobe PDF Library in the main process thread before initialization in any other threads, and terminate the Library in the main process thread after terminating in other threads. This will provide enhanced performance when initializing the Library in a process' child threads.

Access to the same PDF document from multiple threads is not permitted because multiple threads cannot share Adobe PDF Library data types. PDF documents created/opened in the main thread can be only used from the main thread.