#89 Race Condition in Java
Telusko
View ChannelAbout
Hey Aliens Welcome to Telusko! We create technical tutorials that take you from beginner to advanced level. You’ll find content on: Core Programming: Java (Beginner to Advanced), Python, C Programming, Kotlin, Scala, JavaScript Frameworks & Tools: Spring Framework, Hibernate, REST API, Android, Blockchain, Spring AI, AI Engineering Computer Science Essentials: Data Structures, Networking, System Design, and more Trending Tech: Cloud, Microservices, and beyond Alongside technical tutorials, we also share motivational videos and host sessions with leading industry experts. We don’t just stop at free tutorials—we also provide paid courses (live and recorded) and corporate training to help professionals and organizations upskill. So, whether you’re just starting out or sharpening your professional skills, there’s always something here for you. 📩 Business Inquiries: [email protected] 🎓 Explore Live & Recorded Courses: https://telusko.com/
Latest Posts
Video Description
Check out our courses: Java Full Stack and Spring AI - https://go.telusko.com/JavaSpringAI Coupon: TELUSKO10 (10% Discount) DevOps with AWS: From Basics to Mastery : https://go.telusko.com/DevOpsAWS Coupon: TELUSKO10 (10% Discount) Master Java Spring Development : https://go.telusko.com/masterjava Coupon: TELUSKO20 (20% Discount) For More Queries WhatsApp or Call on : +919008963671 Udemy Courses: Spring: https://go.telusko.com/udemyteluskospring Java:- https://go.telusko.com/udemyteluskojava Java Spring:- https://go.telusko.com/Udemyjavaspring Java For Programmers:- https://go.telusko.com/javaProgrammers Python : https://go.telusko.com/udemyteluskopython Git : https://go.telusko.com/udemyteluskogit Docker : https://go.telusko.com/udemyteluskodocker website : https://courses.telusko.com/ In this lecture we will learn: - What are threads and mutations? - Thread safe in Java - Use of join() method in threads - What is synchronization? - Race condition in java #1 Threads and Mutations: - Threads are useful when you want to execute multiple things at the same time. - Most of the time, threads are created by the framework itself. - Threads are used when you want to make things faster. - Mutations simply mean that you can change something. - Primitive type variables and primitive type objects are mutations as their value can be changed. - Strings are immutable as we cannot change their value of it. - Use of threads and mutations at the same time is not good, as it creates instability in the code. #2 Thread Safe: Thread safe means that only one thread will work at one point. - When a thread is already working on an object and preventing another thread from working on the same object, this process is called Thread-Safety. - If we have two threads and each thread is calling increment thousand times, then increment will be called two thousand times. - For the above case, every time you run the code you will get a different output for this. - This happens because the main method prints the value of the count at any moment of time, it does not wait for threads to execute completely and come back to the main method. - If the main method waits for threads to execute and to come back after completion, then it gives nearby correct output. #3 join method and synchronized keyword: - join() is a method that allows the main method to wait for the other threads to come back and join. - join through an exception so we have to handle it by using throws Interruption. - If both threads go to the method at the same time then it might be possible that they will be lost some of the values in between. - The above problem will be resolved by using the synchronized keyword. - By using the synchronized, java ensures that the method will be called by only one method at a time to handle instability in code. - So, if a thread is working with the synchronized method, then the other thread has to wait to work with that method until the first thread gets completed. - Synchronization in java is the capability to control the access of multiple threads to any shared resource. #4 Race condition: - Synchronization helps to prevent the race condition. - Race condition is a condition in which the critical section (a part of the program where shared memory is accessed) is concurrently executed by two or more threads. It leads to incorrect behaviour of a program. Github repo : https://github.com/navinreddy20/Javacode.git Java:- https://bit.ly/JavaUdemyTelusko Spring:- https://bit.ly/SpringUdemyTelusko More Learning : Java :- https://bit.ly/3x6rr0N Python :- https://bit.ly/3GRc7JX Django :- https://bit.ly/3MmoJK6 JavaScript :- https://bit.ly/3tiAlHo Node JS :- https://bit.ly/3GT4liq Rest Api :-https://bit.ly/3MjhZwt Servlet :- https://bit.ly/3Q7eA7k Spring Framework :- https://bit.ly/3xi7buh Design Patterns in Java :- https://bit.ly/3MocXiq Docker :- https://bit.ly/3xjWzLA Blockchain Tutorial :- https://bit.ly/3NSbOkc Corda Tutorial:- https://bit.ly/3thbUKa Hyperledger Fabric :- https://bit.ly/38RZCRB NoSQL Tutorial :- https://bit.ly/3aJpRuc Mysql Tutorial :- https://bit.ly/3thpr4L Data Structures using Java :- https://bit.ly/3MuJa7S Git Tutorial :- https://bit.ly/3NXyCPu Donation: PayPal Id : navinreddy20 https://www.telusko.com
Java Developer's Toolkit Essentials
AI-recommended products based on this video

LEGO Speed Champions Oracle Red Bull Racing RB20 F1 Race Car Model Kits - Building Set for Adults, Ages 18+ with Realistic Features - Red Bull F1 DIY Crafts for Display - Gift Idea for F1 Fans - 77243

Viabrico 10 Pack AF-100 Replacement Spool Line for Black+Decker - 0.065" Weed Eater String Trimmer Line Spool, 30ft Autofeed Weed Wacker Spool Refill for Black+Decker(8 Spool,2 Cap,2 Spring)

MT7601 USB Adapter USB Antenna, Computer Adapter USB Adapter with Integrated Antenna for Windows Desktop Laptop

BrosTrend 1200Mbps USB WiFi Adapter for Windows 11/10/8/7/XP of PC Desktop Laptop, Dual Band 5GHz 867Mbps, 2.4GHz 300Mbps, USB 3.0, Network Card WLAN

BrosTrend AX300 WiFi 6 USB WiFi Adapter for PC, Nano Size WiFi Dongle for Laptop Desktop, USB Wireless Adapter for Windows 11/10/7, 2.4GHz Only, 286Mbps, Wireless Network Adapter, OFDMA (NOT for MAC)

AC600 Nano USB WiFi Adapter for Desktop PC/Laptop, Dual-Band (5GHz, 2.4GHz) Wireless 802.11ac MU-MIMO Network Adapter for Windows & Mac OS, Mini Travel Size WiFi Dongle






















