Developing multithreaded applications is much easier when threads don’t interact, typically via shared variables. When interaction occurs, race conditions, data races, and cached variable problems can arise that make an application thread-unsafe. When using threads, it can cause increased complexity, and debugging your code can become much more difficult. It is possible to add logic to make sure data is synchronized across threads, but too much reliance on synchronization can lead to performance issues, which affect an application’s scalability. A race condition occurs when the correctness of a computation depends on the relative timing or interleaving of multiple threads by the scheduler.
- [Instructor] It's important to understand…some potential problems with using threads in Java.…Developing multithreaded applications…is much easier when threads don't interact,…typically via shared variables.…When interaction occurs, race conditions,…data races, and cached variable problems can arise…that make an application thread-unsafe.…When using threads, it can cause increased complexity,…and debugging your code can become much more difficult.…It is possible to add logic to make sure data…is synchronized across threads,…but too much reliance on synchronization…can lead to performance issues,…which affects an application's scalability.…
A race condition occurs when the correctness…of a computation depends on the relative timing,…or the interleaving of multiple threads by the scheduler.…A data race occurs when two…or more threads in a single application,…access the same memory location concurrently.…At least one thread requires right access,…and these threads don't coordinate…their access to that memory.…When these conditions hold,…
- What is a thread?
- Creating threads
- Syncing threads
- Understanding concurrency
- Working with the Java locking framework