All Questions
Tagged with java multithreading
451
questions
6
votes
2
answers
261
views
A thread-safe performant URL Shortener in Java
This is a popular interview question. It is meant to be done within 45 minutes. The task is to implement a thread-safe performant in-memory URL Shortener.
My implementation is based on two maps that ...
0
votes
0
answers
41
views
Thread pooled bidirectional breadth-first search in Java for graphs with slow node expansion - part I/II: the algorithm
(This post has part II/II.)
Intro
This time, I have this GitHub repository. The idea is that if the graph node expansion is slow (for example, in the case where you ask a web server to return some ...
5
votes
3
answers
94
views
Time based cache for single element
The container should be thread safe and provide lazy load of data, and cache the data for set period of time.
...
1
vote
1
answer
73
views
Multiple Producer and Multiple Consumer Implementation Using Locks and Semaphore
This solution has a total of four classes.
Main.java: Class with main method. Execution starts here.
...
0
votes
1
answer
97
views
decorator for an Executor that allows to get a List of running tasks
As stated in the javadoc below, this is intended for monitoring and debugging. I've found it especially useful for figuring out which tasks got stuck and prevented clean terminations of my ...
3
votes
1
answer
101
views
simple multi-threaded TCP chatroom in Java
I'm fairly new at coding and looking to improve. Down below is all of my files for a TCP chatroom with a GUI in java. This is my first networking project so I'm sure it has many problems and does not ...
2
votes
2
answers
138
views
Thread-safe coordinate holder
I have been given a task to create a thread-safe RobotCluster class. The idea is that there's a set of robots operating on multiple threads and they each submit the ...
1
vote
0
answers
73
views
A parallel MSD radix sort in Java for integer keys
I have this repository: https://github.com/coderodde/ParallelRadixSort.java/tree/main
It contains a parallel MSD radix sort presented below:
...
1
vote
1
answer
197
views
Rate-limited thread scheduler in Java
Background: I'm planning to call different endpoints of a website's API quickly, but the usage policy implies that I may only make five calls in a second. I can't rely on the calls taking 200 ms on ...
4
votes
2
answers
290
views
Multithreaded Conway's Game of Life implementation written in C and Java using JNI
I had some multithreading C programming experience from school last year but I wanted a bit more so I tried to program a Conway's Game of Life implementation from scratch.
Code is mainly written in C ...
4
votes
2
answers
298
views
Multiplayer queue optimisation
I currently have code that is working but I think it can be optimised.
The code waits until a player joins and adds the player to a BlockingQueue if there is
not already a Player waiting then it ...
3
votes
1
answer
152
views
A mutex that can detect certain types of programming error
This mutex prevents concurrent access to a target resource. One key requirement is the ability to be acquired
in a (scheduler) thread and released in a different (worker) thread. Unfortunately this ...
4
votes
2
answers
1k
views
Traffic simulation GUI: an exercise in concurrent programming using threads
To avoid a code dump I have removed most of the code and left the first few lines of constructors and methods and anything relevant. Full code at the bottom.
The purpose of this code is to use threads ...
4
votes
1
answer
151
views
Task executor thread pool
Despite my experience with Java, I am not well-versed with concurrency. I wrote this thread pool that has a queue of tasks. Please ignore any signature choices, such as overuse of ...
1
vote
1
answer
621
views
Thread in a Spring app that watches a directory for new files
Before showing-off the code, here is a bit of an explanation.
I have a Spring component that spawns a thread for watching a directory for new files.
In this context, I have a method that runs in a ...