Teracotta, including the Open Source edition, has distributed locking semantics by using either synchronized
or the java.util.concurrent.ReentrantReadWriteLock
- the latter apparently fitting your requirements.
Update
Since the question now added the requirement of 'mixing' with GigaSpaces, I'm going to say don't mix them. It's just going to add more complexity to your technological stack, and the effort of:
- integrating, in terms of both code and infrastructure;
- managing synchronisation between them;
- learning/tuning/debugging Teracotta.
will be better spent creating or implementing a locking solution based on GigaSpaces.