Multi-threading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).
3
votes
1answer
39 views
Concurrent LRU cache using sychronizedMap() or ReadWriteLock
Trying to implement a simple, thread-safe LRU cache that's meant for "read mostly" use.
Collections.sychronizedMap()
Clean, simple, not much else to say.
...
6
votes
1answer
83 views
Code snippet for a method dealing with IDs from multiple threads
I have multiple threads calling a method, passing in an ID and value.
I have two constraints I need to place on this method:
Only one of the same ID can be processed at a time. Additional threads ...
5
votes
1answer
48 views
TCP Server using NIO to save data from IoT clients
I've built a small single threaded TCP server using NIO.
This server is used by small client devices to report things like temperature, when the device has been switched on, when it switches off, and ...
2
votes
3answers
46 views
Thread safety and performance when multiple threads write into same Writer
Multiple threads write data to a file. When maxLines is reached, the file is closed and a new file is created:
...
3
votes
1answer
43 views
File reader and streamer component running in its own thread on Android
In an Android project,
I have a class whose job is to read lines from a file,
and then pump those lines to a message handling thread,
looping forever until told to stop.
The main operation of this ...
14
votes
1answer
80 views
Coroutines in C
Please have a look at this little coroutines library ccoro: http://sam.nipl.net/code/ccoro
I'd appreciate a general code and style review, and your kind comments!
...
3
votes
2answers
84 views
Simple C++ thread pool
I wrote a minimalistic thread pool using some C++11 features. I've used it on two projects so far and it has worked fine, but when I ran the code on my laptop, I believe that my thread pool might be ...
3
votes
0answers
51 views
Generic GUI background task runner (Java 8+)
Here is the culprit; headers omitted for brevity, and also, see notes afterwards:
...
1
vote
1answer
52 views
Optimizing my program by accessing data locally instead of a remote database
I have a database with 4 tables filled with millions of rows. I have my program run on several computers computing data and then returning it to the database. The huge bottleneck in my program design ...
3
votes
1answer
58 views
Simple concurrent freelist
To become better acquainted with the Intel Parallel Studio XE profilers I'm currently messing around with a simple concurrent freelist. I'm fairly certain that it's thread-safe. It uses Acq/Rel ...
5
votes
1answer
79 views
Beat detection algorithm implementation
What is the quality of the code I've written? Is it easy to read or is it a low-quality piece of code? Also, is there any way I can improve the algorithm itself (beside changing C parameters)?
...
1
vote
0answers
37 views
A Simple Thread Pool in Scala
I wrote the following that spawns n threads, uses them to process a queue of jobs, then returns a result.
As well as any general suggestions, I'd like feedback on the following:
How safe is ...
3
votes
2answers
66 views
Removing synchronization from an agent for a trading system
Is there any way to easily remove synchronization from this code, when there is a validation step before acquiring a lock?
I tried an ...
2
votes
2answers
52 views
Pulling thread data from Invision power board from an external java application
What I am planning on doing is pulling the first post of my news section, this was made for V bulletin and now I need to add it for IPb.
...
3
votes
0answers
41 views
Text-based Snake game on Window - follow-up
Previous question:
Text-based Snake game on Window
Summary of improvements:
Removed unnecessary functions such as clearScreen()
Added new ...
3
votes
2answers
70 views
Is this a thread-safe implementation of background bitmap generation?
For a game implementation, I have a very large overview map with multiple layers (namely base-map / units / highlight & info / fov-shading) of which the first is CPU-intensive to generate. I have ...
6
votes
1answer
48 views
Throttling commands
I have a scenario where my BaseRepository gets a lot of commands in a short time period. At other moments, this doesn't happen. What I want to achieve is to throttle these commands. I.e., when a ...
5
votes
3answers
109 views
Counting letters as quickly as possible
I received a task, of taking a known text file (Linux dictionary), use threads to count the different letters in it, and present the results in an array.
The code doesn't have to be pretty, elegant, ...
11
votes
1answer
108 views
Storing messages for the application's runtime
I am currently writing a well.. manual testing site for a chat-based bot. The full code can be found on github.
For that purpose I had to keep track of the messages currently in the "system". The ...
1
vote
2answers
104 views
Updating list of string while others reading it in Java
I have a logging solution that writes down the hashes of messages. I consider some of these hashes to be safe and I want to skip logging those. I have implemented a whitelist that is a directory ...
3
votes
2answers
496 views
Simple Java Game including Thread
I am a Java beginner and have made a simple Compare Game. It has done well but I am not sure about my solution, especially about my thread. Can you give some advice on making it better?
...
4
votes
1answer
45 views
C++11 class similar to .Net's ManualResetEvent, but without the ability to “reset”
The goal is to block all threads that call WaitOne(). When Set() is called, those threads continue. Any calls to ...
4
votes
0answers
47 views
Simple wrapper class for Win32 console
This is based on a library called Consoledefender V 3.3.
I made a minimal class for personal usage based on this library by using C++11. It actually takes user input and prints it back on the console ...
1
vote
1answer
74 views
1
vote
0answers
54 views
FTP client/server sockets
I'm working on a project using socket programming to design an FTP server/client application. This is the code so far. What I need to do is add authentication, I want users to be able to access ...
1
vote
0answers
53 views
Threaded Video Player sync
I am developing a video player with the following design:
The main thread - is GUI thread (Qt SDK).
Second thread - player thread which accepts commands from the GUI thread to play, forward, ...
7
votes
3answers
721 views
Dining philosophers problem in C++11
Is this implementation correct? Do you find any threading problem? Also, what parts of the code can be changed to be more C++11-ish?
...
3
votes
0answers
95 views
Switching between view controllers that are loaded in the background
I have a dining menu app that scrapes the data from a website and redisplays it in a mobile format, displayed below:
If the user swipes left and right, the app will show the previous/next meal (ex. ...
5
votes
1answer
58 views
Implement a blocking counter with a reader/writer lock
I'm trying to implement a blocking counter that may have several readers and writers at the same time:
...
7
votes
1answer
166 views
Lock Using “Interlocked” vs lock Statement (“Monitor”) (Followup)
This is a followup to a previous question.
Considering:
Interlocked.CompareExchange generates a memory barrier,
Intended to be used with very fast operations ...
4
votes
2answers
97 views
Lock Using “Interlocked” vs lock Statement (“Monitor”)
A followup question can be found here, based on this question and it's answer.
Considering:
Interlocked.CompareExchange generates a memory barrier,
Intended to ...
4
votes
0answers
93 views
Deadlock watchdog in a server to defend against poorly written extensions
In the Red5 server we have no control over what implementers do with their applications and as such we have attempted to implement code that would prevent them from causing bad things to happen.
...
3
votes
0answers
51 views
Parallel MSD radix sort in Java
I have this parallel implementation of MSD radix sort, which processes the entries by one particular byte. At each byte index, it has three phases:
Count the bucket sizes.
Insert each entry to its ...
1
vote
2answers
84 views
Class for multithreaded insert into database
Here I have class that supposed to take dictionaries of product objects and their articles (kind of unique identifier) from queue and insert or update them in database table.
Received dictionary ...
4
votes
1answer
74 views
Optimize the Buddhabrot
I am currently working on my own implementation of the Buddhabrot. So far I am using the std::thread-class from C++11 to concurrently work through the following ...
2
votes
1answer
86 views
Counting words in files - follow-up
I have made a non-threaded version of counting words. The result was unexpected the non-threaded version was faster than threaded-parallel version.
Non-threaded version:
...
4
votes
1answer
130 views
Counting words in files
I made a simple program for my study that calculates words in a text files and prints every word and its repeated times in the files.
How can I improve this code?
...
13
votes
3answers
297 views
Printing all even and odd numbers with threads
The original question is on careercup.
Write a multi threaded C code with one thread printing all even numbers and the other all odd numbers. The output should always be in sequence
ie. ...
5
votes
1answer
44 views
Synchronization Event with awaitAny
In Java, there is no way I know of to wait for multiple events at the same time (see Stack Overflow). Since I would like to use that feature (similar to ...
1
vote
1answer
133 views
TCP Server with multithreading
I am working on a banking application. I want to create a multithreaded TCP Payment Card (iso8583) server that can handle passbook printing requests simultaneously. Multiple devices are connected to ...
1
vote
0answers
28 views
Thread synchronization and happens-before relation in simple examples
I wrote those examples to show different approaches to sharing results between threads. The whole code is on GitHub. All examples should return "Hello world".
Are these OK from the perspective of ...
4
votes
2answers
69 views
Code organization when using threads
From OOP & OOD point of view, is it good idea to define Java-threads inside of the static method or in this case it's better to use instance-based method?
...
1
vote
0answers
29 views
Sum of N primes in parallel-ish
I'm primarily a C# guy--day job, most of my hobby projects, etc. Linq's AsParallel() call would be my normal way of doing something like this, but--tragically!--Rust hasn't stolen that just yet... ...
3
votes
2answers
229 views
Multi threaded TCP server
I wrote this just for fun, to hone my exception handling skills. I want to know what I can do better in terms of exception handling (and otherwise) in the below code
Server
...
6
votes
1answer
126 views
Task scheduler coding exercise
In an interview about multithreading I was asked to write code to satisfy the requirements below:
In the exercise you need to provide implementation of single-threaded TaskScheduler class with the ...
1
vote
2answers
146 views
Producer Consumer in C# with multiple (parallel) consumers and no TPL Dataflow [closed]
I am trying to implement producer/consumer pattern with multiple or parallel consumers.
I did an implementation but I would like to know how good it is. Can somebody do better? Can any of you spot ...
2
votes
2answers
123 views
Using a Java queue
I am developing a plugin for a system, the plugin catches some events in that system, wraps them and pushes out to another system for analysis. The overhead generated by the plugin must be as low as ...
1
vote
1answer
189 views
Saving a collection of WPF user control layout into an XPS document
I am making an application to save a layout of user control into an .xps document. But, the export doesn't seem completed if the data is too many. I've tried to encapsulate each part with ...
0
votes
2answers
47 views
Java background server class that might be called from ui thread
I have a server communicating over network interface. This server should run on a background thread, so that it does not block the ui thread. The ui thread starts and stops the server. Even starting ...
10
votes
2answers
152 views
Implementing JQuery style 'deferred' and 'promise' in C#
I like the pattern of the jQuery Deferred object.
I like how you can call Resolve any number of times, but the listening objects will only be notified once. I also ...