๐ŸŒ
LeetCode
leetcode.com โ€บ discuss โ€บ interview-question โ€บ 889965 โ€บ java-multithreading-hard-question-any-idea
Java Multithreading (Hard) Question. Any idea? - Discuss - LeetCode
I was recently asked a question related to multithreading in java by Morgan Stanley, Q. Imaging you have a List of ids(Integer). Now, a thread is adding new ids in the background and your task is to find if a given id exists or not in the list, taking into account the thread that is regularly adding new values (return true or false).
๐ŸŒ
Reddit
reddit.com โ€บ r/leetcode โ€บ need help with a question i came across recently in a test
r/leetcode on Reddit: Need help with a question I came across recently in a test
October 16, 2023 -

I was able to come up with a graph traversal solution but couldn't get all the test cases.

Question:

There are service_nodes of different micro-services in a system with bidirectional connections in the form of a tree (acyclic graph), where the ith edge connects the micro-services service_from[i] and service_to[i]. Each micro-service is configured with a maximum number of live threads that can be present in its lifecycle, where the ith micro-service can have a maximum of threads[i] threads. The micro-services adjacent to each other must have maximum threads differing by exactly 1.

Some configurations were lost, and only k of the micro-services are known. This information is given as a 2D array, currentValues, of size k x 2 denoting [micro-service index, maximum threads], or, [i, threads[i]]

Find the maximum number of live threads that each micro-service can have such that the total number of live threads in the system is the minimum possible. Return an array of length service nodes where the element denotes the maximum number of live threads for the micro-service.

Note: It is guaranteed that the solution always exists.

Constraints 1 <= node_count <= 105 number of given values for nodes <= node_count 1 <= value of a node <= 105

Example

given graph => (1:3)-(2:x)-(3:x)-(4:x)-(5:3) node 1 to 5 (given) for nodes 1 and 5, we have been given the max thread value as 3 and 3, respectively we need to find all x values such that max sum is minimum and adjacent nodes differ by 1 solution for the above graph => (1:3)-(2:2)-(3:1)-(4:2)-(5:3) so we return [3,2,1,2,3]

๐ŸŒ
YouTube
youtube.com โ€บ watch
All Leetcode Multithreading questions solved - YouTube
In this video I have discussed solutions to all multithreading questions present on leetcode.Implemented in C++17https://leetcode.com/problems/print-in-order...
Published ย  June 11, 2023
๐ŸŒ
LeetCode
leetcode.com โ€บ problems โ€บ print-in-order
Print in Order - LeetCode
Print in Order - Suppose we have a class: public class Foo { public void first() { print("first"); } public void second() { print("second"); } public void third() { print("third"); } } The same instance of Foo will be passed to three different ...
๐ŸŒ
LeetCode
leetcode.com โ€บ problemset โ€บ concurrency
LeetCode - The World's Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
๐ŸŒ
Reddit
reddit.com โ€บ r/leetcode โ€บ resources for must knows of java multithreading/concurrency
r/leetcode on Reddit: Resources for must knows of Java Multithreading/Concurrency
October 24, 2021 -

Okay, I have read/watched jevkov's videos and blogs. But how can i prepare for FAANG interviews? Last time, this interviewer from Goldman had me trippin' answering questions regarding why use singleton pattern, and what occasion I should use multi-threading. But at my job, I did notice there were tests that implements Runnable interface that is multithreaded, and threadcontext on the controller level. So Im not really exposed to multithreading.

Could someone please share some concise resources that gives insights into must know fundamentals of Java Multithreading/concurrency to prepare for FAANG interviews? Thanks

Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ acing-the-software-engineer-interview โ€บ interview-practice-problem-for-multithreading-8f3830cce844
Interview Practice Problems for Multithreading | by LiveRunGrow | Acing the Software Engineer Interview | Medium
June 14, 2023 - When you use the synchronized keyword in Java, it provides built-in locking mechanism to ensure that only one thread at a time can execute the synchronized block or method.
๐ŸŒ
AlgoMonster
algo.monster โ€บ liteproblems โ€บ 1242
1242. Web Crawler Multithreaded - In-Depth Explanation
In-depth solution and explanation for LeetCode 1242. Web Crawler Multithreaded in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2014 โ€บ 07 โ€บ top-50-java-multithreading-interview-questions-answers.html
Top 50 Java Thread and Concurrency Interview Questions Answers for 2 to 5 Years Experienced
See my blog post on the same topic for a more in-depth answer to this question. 8) What is the difference between CyclicBarrier and CountDownLatch in Java? (answer) Though both CyclicBarrier and CountDownLatch wait for a number of threads on one or more events, the main difference between them is that you can not re-use CountDownLatch once the count reaches to zero, but you can reuse the same CyclicBarrier even after the barrier is broken. See this answer for a few more points and a sample code example.
๐ŸŒ
LeetCode
leetcode.com โ€บ discuss โ€บ interview-question โ€บ operating-system โ€บ 4582744 โ€บ Multi-Thread-Programming-and-OS
Multi Thread Programming and OS - Discuss - LeetCode
January 17, 2024 - There are two main problems that usually happen on dealing with multi thread programming : 1- Race condition: - when we do not protect the resource with any
๐ŸŒ
LeetCode
leetcode.com โ€บ problems โ€บ fizz-buzz-multithreaded
Fizz Buzz Multithreaded - LeetCode
Fizz Buzz Multithreaded - You have the four functions: * printFizz that prints the word "fizz" to the console, * printBuzz that prints the word "buzz" to the console, * printFizzBuzz that prints the word "fizzbuzz" to the console, and * printNumber ...
๐ŸŒ
Java67
java67.com โ€บ 2012 โ€บ 08 โ€บ 5-thread-interview-questions-answers-in.html
Top 12 Java Thread, Concurrency, and Multithreading Interview Questions Answers | Java67
There are basically two ways to solve this problem in Java, One by using the wait and notify method and the other by using BlockingQueue in Java. later is easy to implement and a good choice if you are coding in Java 5. The key points to mention, ...
๐ŸŒ
LeetCode
leetcode.com โ€บ discuss โ€บ interview-question โ€บ 1209950 โ€บ multithreading-problem-need-help-to-code-this-problem
Multithreading Problem | Need help to code this problem - Discuss - LeetCode
May 15, 2021 - Problem statement: Write a Java program that simulates a Water manufacturing factory. Your factory has infinitely capable Hydrogen and Oxygen producer units (i
๐ŸŒ
LeetCode
leetcode.com โ€บ problem-list โ€บ concurrency
Problem List - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 78226701 โ€บ leetcode-1116-java-concurrency-issue-will-waiting-thread-revisit-code-before
wait - LeetCode 1116 Java Concurrency Issue, will waiting thread revisit code before? - Stack Overflow
Once there's sufficient detail to answer, vote to reopen the question. Closed last year. ... Here is my code for the problem which works fine, however, when I change the while statement right under synchronized statement, it seems any thread that get the lock after notifyall() just continue to run the code and causing odd method accept even number, even method accept odd number. class ZeroEvenOdd { private int n; private AtomicInteger counter; private AtomicInteger mode; private Object lock; public ZeroEvenOdd(int n) { this.n = n; this.counter = new AtomicInteger(0); this.mode = new AtomicInte
๐ŸŒ
LeetCode
leetcode.com โ€บ problems โ€บ single-threaded-cpu
Single-Threaded CPU - LeetCode
Single-Threaded CPU - You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the i th task will be available to process at enqueueTimei and will take ...
๐ŸŒ
InterviewBit
interviewbit.com โ€บ multithreading-interview-questions
Top Java Multithreading Interview Questions (2025) - Interviewbit
One cannot reuse the same CountDownLatch once the count reaches 0. Inter-thread communication, as the name suggests, is a process or mechanism using which multiple threads can communicate with each other. It is especially used to avoid thread polling in java and can be obtained using wait(), notify(), and notifyAll() methods.