Quote:How do i implement a c program that is able to read from multiple files using multithreading and locks
Since Linux does not support threads directly, it is necessary to use the Posix library. It should be noted that all threads are terminated when the main thread is terminated. The threads can then be created with pthread_create(). To prevent the main thread from terminating prematurely, the pthread_join() function can be used to wait until all threads have terminated. The <pthread.h> header and the -lpthreads compiler option must be used.
File locks are used for mutual exclusion when a file is to be read and written by multiple processes, but if I interpret the heading correctly, different files are to be read here with multithreading. Locks would not be necessary for this.
Note: The Linux implementation of mandatory locking is unreliable. The Advisory Locking alternative requires cooperation between the processes involved.