As valdir.marcos posted, that was a multithreading example with Firebird database.
But keep in mind, your table structure must have index that able to split queries into a small sections. Without this ability, forget about multithreading.
After split into small sections, assign each section to each thread. From my experience, max thread created is about 75% of hardware thread. For ex. if your cpu has 8 threads, # of thread created in Lazarus is 6 (8x75%).