Day 36 of my AI-Powered Java Full Stack Journey Day 36 : Today I learned about wait(), notify(), and notifyAll() in Java. 1. wait(): is used to pause a thread until some condition is met. 2. notify(): wakes up one waiting thread. 3. notifyAll(): wakes up all waiting threads. These concepts are important in multithreading to control how threadsgive day 3 communicate with each other. Slowly understanding how Java works internally Day 37: Learned about Callable and Try-with-Resources. Callable is used to return a result from a thread. Try-with-Resources helps to automatically close resources like files and connections. Simple concepts, but very useful in real-world applications 👍 Thank you Fayaz S sir for your contant guidance. Github: https://lnkd.in/gy3DjmFN #Java #FullStack #Multithreading #Callable #100DaysOfCode #CodingJourney #LearnJava
Java Multithreading with wait(), notify(), Callable and Try-with-Resources
More Relevant Posts
-
Day 56-What I Learned In a Day (JAVA) Today I learned an important concept in Java - how to access non-static members, both within the same class and across different classes, along with the concept of code reusability. Accessing Non-Static Members within the Same Class Non-static members belong to an object, so they can be accessed directly inside non-static methods. Key point: No object creation is needed when accessing inside the same class’s non-static method. Accessing Non-Static Members from Another Class To access non-static members from a different class, we must create an object of that class. Example: ClassName obj = new ClassName(); obj.methodName(); This allows us to call methods and use variables defined in another class. Code Reusability One of the biggest advantages I understood today is code reusability. Instead of writing the same logic again: • We create a method once • Reuse it in multiple classes using objects This reduces: • Code duplication • Errors • Development time #Java #OOP #CodeReusability #Programming #LearningJourney #DeveloperLife
To view or add a comment, sign in
-
-
Day 55-What I Learned In a Day (JAVA) Today, I learned how to create and use constructors in Java. 🔹 A constructor is a special method used to initialize an object when it is created. 🔹 Constructors are non-static by default, meaning they work with objects and help assign values to instance variables. 🔹 They are automatically executed when an object is created, making object initialization simple and efficient. 🔹 This reduces the need for setting values manually after object creation. Understanding constructors helped me see how Java initializes objects in a structured and efficient way. #Java #OOP #Constructors #LearningJourney #Programming #TechSkills
To view or add a comment, sign in
-
Multithreading in Java finally clicked for me when I stopped memorizing it… and started visualizing it. 🧠 Here’s the simplest way to understand it: Imagine your application is doing only ONE task at a time. ➡️ Slow ➡️ Blocking ➡️ Poor performance Now introduce multithreading 👇 Multiple tasks run simultaneously: ✔ One thread handles API requests ✔ One processes data ✔ One writes logs Result? Faster and more efficient applications 🚀 But here’s what I learned the hard way: Multithreading is powerful… but dangerous if not handled properly. Common issues I faced: Race conditions Deadlocks Unexpected bugs What helped me: ✔ Proper synchronization ✔ Understanding thread lifecycle ✔ Using ExecutorService instead of manual threads Lesson: Multithreading is not just about speed — it’s about control and correctness. 💬 Have you faced any tricky bugs with multithreading? #Java #Multithreading #BackendDevelopment #SoftwareEngineering #Coding
To view or add a comment, sign in
-
Day 53 of Sharing What I’ve Learned 🚀 ArrayDeque in Java — Fast & Flexible Queue Alternative After understanding how LinkedList works as a Queue, I explored a more optimized and powerful structure in the Java Collections Framework — ArrayDeque 🔹 What is ArrayDeque? ArrayDeque is a resizable array-based implementation of a Deque (Double-Ended Queue). 👉 It allows insertion and deletion from both ends efficiently. 🔹 Why use ArrayDeque over LinkedList? ✔ Faster Performance No node traversal → better speed compared to LinkedList. ✔ No Extra Memory Overhead Doesn’t store pointers like LinkedList → more memory efficient. ✔ Better Cache Performance Elements are stored contiguously → faster access. ✔ Acts as Stack + Queue Can be used as: Stack (LIFO) Queue (FIFO) Deque (both ends) 🔹 Key Operations ✔ addFirst() / addLast() ✔ removeFirst() / removeLast() ✔ peekFirst() / peekLast() 🔹 When should we use ArrayDeque? 👉 Use ArrayDeque when: ✔ You need fast insertions/deletions at both ends ✔ You want a better alternative to Stack or LinkedList ✔ Performance matters (less overhead) 🔹 When NOT to use? ❌ When you need random access (indexing) ❌ When frequent middle operations are required 🔹 Key Insight 💡 Not all Queues are equal — 👉 Choosing the right implementation (LinkedList vs ArrayDeque) can significantly impact performance. 🔹 Day 53 Realization 🎯 Efficiency isn’t just about solving problems — 👉 It’s about solving them smartly with the right tools. #Java #ArrayDeque #DataStructures #CollectionsFramework #Programming #DeveloperJourney #100DaysOfCode #Day53 Grateful for guidance from, Sharath R TAP Academy
To view or add a comment, sign in
-
-
💻 Day 19 of My Java Journey Today I explored Generics, and it made Java feel much cleaner. Instead of writing separate code for different data types, generics allow us to write one reusable piece of code. Using <T> as a placeholder, we can handle multiple data types safely without worrying about runtime errors. This is one of those concepts that improves both code quality and flexibility. Learning something new every day 🚀 #Java #Programming #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
Day 7 of #100DaysOfCode — Java is getting interesting ☕ Today I explored the Java Collections Framework. Before this, I was using arrays for everything. But arrays have one limitation — fixed size. 👉 What if we need to add more data later? That’s where Collections come in. 🔹 Key Learnings: ArrayList grows dynamically — no size worries Easy operations: add(), remove(), get(), size() More flexible than arrays 🔹 Iterator (Game changer) A clean way to loop through collections: hasNext() → checks next element next() → returns next element remove() → safely removes element 🔹 Concept that clicked today: Iterable → Collection → List → ArrayList This small hierarchy made everything much clearer. ⚡ Array vs ArrayList Array → fixed size ArrayList → dynamic size Array → stores primitives ArrayList → stores objects Still exploring: Set, Map, Queue next 🔥 Consistency is the only plan. Showing up every day 💪 If you’re also learning Java or working with Collections — let’s connect 🤝 #Java #Collections #ArrayList #100DaysOfCode #JavaDeveloper #LearningInPublic
To view or add a comment, sign in
-
I just discovered Virtual Threads in Java and my mind is blown. I've been learning Java concurrency for a while now and honestly… it was painful. Thread pools. ExecutorService. CompletableFuture chains. Reactive streams. I kept thinking "there HAS to be a simpler way." Turns out… there is - Virtual Threads. Here's what blew my mind: → You can spin up MILLIONS of threads without crashing your app → You write normal, boring, sequential code… and it just scales → No more callback hell → No more guessing thread pool sizes → No more choosing between "readable" and "performant" The code went from this: CompletableFuture.supplyAsync(() -> fetchData()) .thenApply(data -> process(data)) .thenAccept(result -> save(result)) .exceptionally(ex -> handleError(ex)); To this: Thread.ofVirtual().start(() -> { var data = fetchData(); var result = process(data); save(result); }); Same result. Half the complexity. 10x more readable. I'm still learning and I'm sure there's more to it. But if you're a Java developer and you haven't looked into Virtual Threads yet, do yourself a favor and try it this weekend. #Java #LearningInPublic #VirtualThreads #Programming #SoftwareDevelopment #CodeNewbie #BackendDev
To view or add a comment, sign in
-
🚀 Mastering Java Through LeetCode 🧠 Day 32 Today I solved an Easy-level Tree problem that strengthened my understanding of Recursion + Depth Calculation — a fundamental concept for tree-based problems 📌 LeetCode Problem Solved: Q.104. Maximum Depth of Binary Tree 💭 Problem Summary: Given a binary tree, the task is to find the maximum depth — i.e., the number of nodes along the longest path from root to leaf. 🧠 Approach (Optimal): Instead of iterating level by level, I used a clean recursive approach: ✔️ If node is null → return 0 ✔️ Recursively calculate left subtree depth ✔️ Recursively calculate right subtree depth ✔️ Return 1 + max(left, right) ⚡ Key Learning: Recursion makes tree problems much simpler when you think in terms of “what should each function return for a node?” Complexity: Time: O(n) Space: O(h) Takeaway: Tree problems become easier once you master recursion and start recognizing patterns. Consistency is the key — showing up every day #Day32 #LeetCode #Java #DSA #CodingJourney #Recursion #BinaryTree #100DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 10/100 – Java Practice Challenge 🚀 Continuing my #100DaysOfCode journey with another important Java concept. 🔹 Topic Covered: Polymorphism Polymorphism means “many forms” — the same method behaves differently depending on the object. 💻 Practice Code: 🔸 Example Program class Animal { void sound() { System.out.println("Animal makes sound"); } } class Dog extends Animal { @Override void sound() { System.out.println("Dog barks"); } } public class Main { public static void main(String[] args) { Animal a = new Dog(); // Upcasting a.sound(); // Runtime polymorphism } } 📌 Key Learnings: ✔️ Same method → different behavior ✔️ Achieved using method overriding ✔️ Based on object type (runtime) 🎯 Focus: Understanding dynamic behavior using inheritance and method overriding 🔥 Interview Insight: Polymorphism is a core OOP concept and widely used in real-world applications. #Java #100DaysOfCode #Polymorphism #OOP #JavaDeveloper #Programming #LearningInPublic
To view or add a comment, sign in
-
A lot of us use inheritance in Java, but we don’t always pause to think about what it really means. In simple terms, inheritance is just a way to reuse code. One class takes properties and behavior from another class, so you don’t have to write the same logic again. There are a few common ways this shows up: Single inheritance is the basic one. One parent class, one child class. Multilevel inheritance is like a chain. A class inherits from another class, which itself inherited from someone else. Hierarchical inheritance is when one parent class is shared by multiple child classes. Java doesn’t support multiple inheritance with classes, but you can achieve something similar using interfaces. A class can implement multiple interfaces and get behavior from all of them. Hybrid inheritance is just a combination of these approaches, usually involving interfaces. The real benefit is simple. Less duplication, better structure, and code that’s easier to maintain. If you overuse inheritance, your code can become tightly coupled and harder to change. In real projects, don’t just use inheritance blindly, use it when there is a clear relationship. #Java #OOP #SystemDesign #CleanCode #SoftwareEngineering
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development