my resources are of same type and I do not care which one is accessed by which thread.
Ok we have a limited number of resources that do the same thing eg 10 pencils and you need to make sure that every thread that requests one either gets one or waits until one becomes available. In that case you need to use a counting semaphore protecting a TQueue.
I create a list of resources and assign one lock to list when a thread request resource Request method enter to critical section and search list for a free resource if that exists assign it to thread if all resources are in use enter to list lock critical section and when a resource release try enter to list lock and release lock but this routine cause exceptions in critical sections and i don't know why ?
another bug of that routine is if I have two resources lists; lock a list cause lock all requests to another lists.
Not knowing how you protect things or with out any code to glare at, there is no chance to even begin to understand where the problem is.
EDIT:Ok it seems that fpc does not have any semaphore implementation so you need to write your own or use the system objects, if you can't figure things post a small example of your current implementation, along with information on the target OS and application bitness and I'll try to enhance it for you.