How to sync two threads in multithreaded application?



How to sync two threads in multithreaded application?..

Answer / Vikash Bharati

"Two threads can be synchronized in a multithreaded application using various mechanisms such as locks, wait and notify, and semaphores. One common approach is to use the `synchronized` keyword to ensure that only one thread can access a critical section of code at a time. Another approach is to use the built-in classes `java.util.concurrent.locks.ReentrantLock` and `java.util.concurrent.Semaphore`."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Operating Systems General Concepts Interview Questions

How do I find my os version?

1 Answers  


What is dining philosophers’ problem?

1 Answers  


Page replacement algorithm in Operating System?

1 Answers   Impetus,


What is a job queue?

1 Answers  


How does dynamic loading aid in better memory space utilization?

1 Answers  


What does the safe mode do?

1 Answers  


Difference between a thread and process?

1 Answers   Wipro,


What is INODE?

1 Answers   Infosys,


In the context of memory management, what are placement and replacement algorithms?

1 Answers  


What is sock_stream?

1 Answers  


Does overheating cause blue screen?

1 Answers  


How do I clean up program files?

1 Answers  


Categories