What is the role of `ReentrantLock` in thread safety in Java?
`ReentrantLock` ensures that a thread can acquire multiple locks at the same time, which is important for preventing deadlocks.
Thatâ€™s incorrect. While `ReentrantLock` allows a thread to acquire the same lock multiple times, it does not allow multiple locks to be acquired simultaneously. Itâ€™s used to manage locking in critical sections.
Can you describe how `ReentrantLock` is used to prevent deadlocks in a multithreaded program?