[BUGFIX] Implement locking in ClassLoader

After cache clearing we can run in the situation that 2 processes will
rebuild the ClassLoader cache which will lead to a non useable cache,
which produces fatals. As the data is generated more than once the load
of the server increases per request while ClassLoader cache is build.

The implemented Locking will stop this issue. Every process waits till
the first is ready and then looks if data was generated and stops re-
generating the cache.

To-Do: Make it work also for first time installation when there is
no typo3temp/ directory yet.

Resolves: #55099
Releases: 6.2
Change-Id: I9c1916b5b5860e86fe19a1fc292d8ab5a196d960
Reviewed-on: https://review.typo3.org/28480
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny