Day 64 of Sharing What I’ve Learned 🚀 Understanding Multithreading — From Programs to Threads After exploring how Java collections help manage and traverse data efficiently, I started looking into something equally important — how programs actually execute and handle multiple tasks. That’s where multithreading comes in. Before diving deeper into threads, I decided to revisit the fundamentals and build a clearer understanding first: 🔹Program A program is simply a set of instructions written in a language like Java. It’s what we write — but not yet running. 🔹Process When we run a program, it becomes a process. A process is an active instance of a program with its own memory and resources. 🔹Thread A thread is an independent set of code or the smallest unit of execution inside a process. Each process can have multiple threads working simultaneously. 🔹Multithreading Multithreading means running multiple threads within a single process. Instead of doing tasks one by one, we can perform multiple operations at the same time. 🔹Why it matters In real-world applications, tasks often need to happen together: 👉 Handling multiple users in an application 👉 Performing background tasks 👉 Improving performance and responsiveness Without multithreading, everything would run sequentially — slower and less efficient. 🔹Simple perspective Program → What we write Process → What runs Thread → What actually executes 🔹My realization Until now, I focused on how data is stored and traversed. Now it’s time to understand how execution can be optimized and made more efficient. 👉 Collections manage data 👉 Threads manage execution And both together are what make applications powerful. This is just the beginning — next, I’ll dive into how to create and manage threads in Java. #Java #Multithreading #Programming #JavaDeveloper #100DaysOfCode #DeveloperJourney #Day64 Grateful for guidance from TAP Academy Sharath R kshitij kenganavar
Understanding Multithreading in Java
More Relevant Posts
-
🚀 ArrayList Deep Dive — Beyond the Basics. (https://lnkd.in/gUuBbkwb) ArrayList, as part of Java’s Collections Framework, represents a resizable array that bridges the gap between fixed-size arrays and dynamic data structures. It allows elements to grow and shrink automatically, providing fast index-based access while handling memory management internally. Here are the key takeaways from the ArrayList session at TAP Academy by Sharath R. Sir: → Why collections can’t store primitives, and how AutoBoxing handles it → Why for-each loops are preferred in real-world scenarios → Iterator vs ListIterator — forward vs bidirectional traversal → Why add() in the middle is O(n), but get() is O(1) → The key difference between retainAll() and removeAll() One interesting takeaway: there’s no direct way to check an ArrayList’s capacity—you rely on internal behavior and documentation. Reinforces how important it is to understand internals, not just APIs. To know everything in detail I Built a small interactive study guide with quizzes and code snippets to reinforce the concepts. visit site: https://lnkd.in/gUuBbkwb #Java #DSA #Collections #LearningInPublic #SoftwareEngineering #TAPTAP Academy #ArrayList
To view or add a comment, sign in
-
-
Day 56 of Sharing What I’ve Learned🚀 TreeSet in Java — Sorted & Unique Elements After exploring how LinkedHashSet maintains insertion order, I moved to something even more powerful — TreeSet. 👉 It not only stores unique elements but also keeps them automatically sorted 🔹 What is TreeSet? TreeSet is an implementation of the Set interface that stores unique elements in sorted order. 👉 It is internally based on a Red-Black Tree (self-balancing binary search tree) 🔹 How does TreeSet store & sort data? 👉 Elements are stored in a tree structure, not randomly 👉 While inserting, elements are placed in a way that keeps the tree balanced 👉 Data is always arranged in ascending order (default) ✔ Smallest element → left side ✔ Largest element → right side ✔ In-order traversal → gives sorted output 🔹 Why use TreeSet? ✔ Sorted Data Elements are always in ascending order ✔ No Duplicates Just like other Sets, duplicates are not allowed ✔ Navigable Operations Supports methods like higher(), lower(), ceiling(), floor() 🔹 Key Features ✔ Stores unique elements ✔ Automatically sorts elements ✔ Does NOT allow null values ✔ Slower than HashSet & LinkedHashSet (due to sorting) 🔹 Important Methods ✔ add() ✔ remove() ✔ contains() ✔ first() / last() ✔ higher() / lower() 🔹 When should we use TreeSet? 👉 Use TreeSet when: ✔ You need sorted data ✔ You want range-based operations ✔ You need navigation (greater/smaller elements) 🔹 When NOT to use? ❌ When order doesn’t matter → use HashSet ❌ When insertion order matters → use LinkedHashSet ❌ When performance is critical (faster ops needed) 🔹 Key Insight 💡 TreeSet is like a self-sorting set — 👉 You don’t sort the data, it sorts itself automatically 🔹 Day 56 Realization 🎯 Data structures are not just about storing data… 👉 they define how efficiently you can retrieve, organize, and use it #Java #TreeSet #DataStructures #CollectionsFramework #Programming #DeveloperJourney #100DaysOfCode #Day56 Grateful for guidance from, Sharath R TAP Academy
To view or add a comment, sign in
-
-
Day 73 of #90DaysDSAChallenge Solved LeetCode 451: Sort Characters By Frequency Learned an important Java design concept today. Problem Overview: The task was to sort characters in a string based on descending frequency. What confused me initially: Why create a separate Freq class instead of just using HashMap and PriorityQueue directly? Key Learning: PriorityQueue stores one complete object at a time. For this problem, each item needs two pieces of data together: Character Frequency Example: Instead of storing: e and 2 separately We package them as: Freq('e', 2) That custom class acts like a container holding both values in one object, so PriorityQueue can compare and sort them correctly. Why this matters: This taught me that custom classes in Java are often not about complexity, they simply bundle related data into one manageable unit. Alternative approach: We can also use Map.Entry<Character, Integer> instead of creating a custom class, but building Freq makes the logic easier to understand while learning. Today’s takeaway: Not every class is for business logic — sometimes it exists just to package data cleanly. #Java #90DaysDSAChallenge #LeetCode #PriorityQueue #HashMap #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 55 of #100DaysOfCode — Getting Started with Multithreading in Java Over the past 2 days, I explored one of the most important concepts in Java: Multithreading 🔥 💡 What I Learned 🧵 What is Multithreading? Multithreading allows a program to execute multiple tasks simultaneously, improving performance and efficiency ⚡ 👉 Instead of running tasks one after another, we can run them in parallel. ⚙️ Creating Threads in Java 1️⃣ Using Thread Class Extend the Thread class Override the run() method Start using start() 2️⃣ Using Runnable Interface (Best Practice ✅) Implement Runnable Pass it to a Thread object Start execution using start() 🧠 Key Takeaways ✔ Runnable is preferred over Thread (better design & flexibility) ✔ Supports multiple inheritance ✔ Separates task from execution ✔ Helps in building scalable backend systems ⚠️ Important Concept 👉 Difference between: run() ❌ (normal method call) start() ✅ (creates new thread) 🔥 Real-World Use Cases Backend APIs Payment systems Real-time applications Inventory & billing systems (like the one I'm building 🏪) 🚀 What’s Next? ➡️ Synchronization ➡️ Race Conditions ➡️ ExecutorService (Thread Pool) Learning multithreading feels like unlocking a new level in Java 💪 Huge thanks to my mentor Suresh Bishnoi for simplifying complex concepts like multithreading and pushing me to keep learning consistently. #Java #Multithreading #100DaysOfCode #BackendDevelopment #LearningJourney
To view or add a comment, sign in
-
-
#Day 1 of revising Java. Today I focused on refreshing the fundamentals: • Data types • Taking input using Scanner • Object creation • Loops (for / enhanced for) • Conditional statements Going back to the basics is helping me strengthen my programming foundation before diving deeper into problem solving and data structures. The goal for the next few weeks is simple: practice consistently, improve logic, and become more comfortable writing clean Java code. Small progress every day. #Java #Programming #LearningInPublic #CodingJourney #JavaBasics
To view or add a comment, sign in
-
-
Day 52 of Sharing What I’ve Learned 🚀 LinkedList in Java — Advantages & Disadvantages After exploring how LinkedList powers structures like Queue, I took a step back to understand something important — 👉 When should we actually use LinkedList, and when should we avoid it? 🔹 Advantages of LinkedList ✔ Dynamic Size No need to define size in advance — it grows and shrinks as needed. ✔ Efficient Insertions & Deletions Adding/removing elements is fast, especially at the beginning or middle. (No shifting like arrays!) ✔ Memory Utilization (Flexible Allocation) Memory is allocated as needed, not wasted upfront. ✔ Implements Multiple Structures Can be used as: ✔ List ✔ Queue ✔ Deque 🔹 Disadvantages of LinkedList ❌ More Memory Usage Each node stores extra references (pointers), increasing memory overhead. ❌ Slow Access (No Indexing) Unlike ArrayList, you can’t directly access elements — traversal is required. ❌ Poor Cache Performance Elements are not stored contiguously → slower compared to arrays. ❌ Not Ideal for Searching Searching is O(n), making it inefficient for large datasets. 🔹 LinkedList vs ArrayList (Quick Insight) 👉 Use LinkedList when: ✔ Frequent insertions/deletions ✔ Working with Queue/Deque 👉 Use ArrayList when: ✔ Fast access is needed ✔ More read operations than write 🔹 Key Insight 💡 Every data structure has trade-offs — 👉 The real skill is knowing when to use which one. 🔹 Day 52 Realization 🎯 Understanding limitations is just as important as learning features — That’s what makes you a better problem solver. #Java #LinkedList #DataStructures #CollectionsFramework #Programming #DeveloperJourney #100DaysOfCode #Day52 Grateful for guidance from, Sharath R TAP Academy
To view or add a comment, sign in
-
-
Day 58 of Sharing What I’ve Learned 🚀 Map in Java — Storing Data as Key-Value Pairs After learning how PriorityQueue processes elements based on priority, I explored another powerful concept — Map. 👉 It doesn’t store just values… it connects keys with values 🔹 What is a Map? Map is a part of the Java Collections Framework that stores data in key-value pairs. 👉 Each key is unique and maps to a value 🔹 How does Map work? 👉 Data is stored as (key → value) 👉 Keys must be unique 👉 Values can be duplicated ✔ put() → adds key-value pair ✔ get() → retrieves value using key ✔ remove() → deletes entry ✔ containsKey() → checks key existence 🔹 Types of Map ✔ HashMap → Fast, unordered ✔ LinkedHashMap → Maintains insertion order ✔ TreeMap → Sorted by keys 🔹 Why use Map? ✔ Fast lookup using keys ✔ Efficient data organization ✔ Useful for real-world mappings 🔹 Real-World Use Cases 👉 Storing student data (ID → Name) 👉 Caching systems 👉 Frequency counting 👉 Database indexing 🔹 Key Features ✔ No duplicate keys ✔ Allows one null key (HashMap) ✔ Not synchronized (HashMap) ✔ Faster retrieval compared to lists 🔹 When should we use Map? 👉 Use it when: ✔ You need fast lookup by key ✔ You want structured data (pair format) ✔ You need efficient searching 🔹 When NOT to use? ❌ When you only need a list of values ❌ When order matters strictly (use LinkedHashMap/TreeMap carefully) 🔹 Key Insight 💡 Map is not about storing data… 👉 It’s about connecting data 🔹 Day 58 Realization 🎯 Efficient programs don’t just store values… 👉 They organize relationships between them #Java #Map #HashMap #DataStructures #CollectionsFramework #Programming #DeveloperJourney #100DaysOfCode #Day58 Grateful for guidance from, Sharath R TAP Academy kshitij kenganavar
To view or add a comment, sign in
-
-
🚀 Starting My Java Journey I’ve recently started learning Java and diving into Data Structures & Algorithms. So far, I’ve learned: • Basics of Java (variables, loops, conditions) • Arrays and how to work with them • Solving beginner problems on LeetCode I’m really enjoying the process of solving problems and improving my thinking skills. Looking forward to building projects and sharing my progress here! If you have any tips or resources, feel free to share 💻 #Java #DSA #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 56 & 57 – Mastering Maps in Java | Tap Academy Diving deeper into the Java Collections Framework, I explored one of the most powerful concepts — Maps, especially HashMap, LinkedHashMap, and TreeMap. 🔹 Day 56 Highlights – HashMap Understood how Map stores data in key–value pairs Learned internal working: Hashing (Hash Table + Hash Function) Explored default capacity (16) and load factor (75%) Practiced key features: ✔ No duplicate keys ✔ Allows null values ✔ Heterogeneous data support ✔ Fast operations → O(1) 💻 Implemented important methods: put(), get(), containsKey(), containsValue(), entrySet(), keySet(), values() 🔁 Learned how to iterate using: entrySet() (Map → Set conversion) Iterator (cursor-based access) 🔹 Day 57 Highlights – LinkedHashMap & TreeMap 📌 LinkedHashMap Maintains insertion order Same features as HashMap but ordered output 📌 TreeMap Stores data in sorted order (ascending by keys) Uses Tree structure (Red-Black Tree) No null keys allowed Slightly slower → O(log n) 📊 Comparison Insight HashMap → Fastest, no order ⚡ LinkedHashMap → Maintains insertion order 📌 TreeMap → Sorted order 🔄 🎯 Key takeaway: Choosing the right data structure matters based on requirement — speed, order, or sorting. 🎯 This journey is strengthening my problem-solving skills and deepening my understanding of how real-world data is handled efficiently. #Java #CollectionsFramework #HashMap #LinkedHashMap #TreeMap #DataStructures #FullStackJava #TapAcademy #LearningJourney 🚀
To view or add a comment, sign in
-
-
Day 14 of my coding journey — Extracting Unique Words using Java Streams Today I explored a clean and efficient way to extract unique words from a string using Java Streams. Instead of writing multiple loops and conditional checks, I leveraged the power of functional programming: Grouped words using a frequency map Filtered out words that appear more than once Collected only truly unique words in a concise pipeline What I really liked about this approach is how readable and expressive the code becomes. It clearly shows what we want to achieve rather than how step-by-step. Key takeaway: Writing optimized code is not just about performance — it’s also about clarity, maintainability, and using the right abstractions. Every day I’m getting more comfortable thinking in terms of streams, transformations, and data flow. If you have alternative approaches or optimizations, I’d love to hear them. #Day14 #Java #CodingJourney #JavaStreams #BackendDevelopment #ProblemSolving #CleanCode
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