Explain the concept of multithreading in Java and how you ensure thread safety in a concurrent execution environment.