Multi-threading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).

learn more… | top users | synonyms (2)

0
votes
0answers
7 views

Receiving a JSON string response from a URL

I am using RestTemplate as my HttpClient to execute a URL while the server will return a JSON string as the response. The ...
2
votes
0answers
27 views

Neural Network Simulator with OpenMP

I wrote a simple neural network simulator (the biophysical kind) from scratch, and was hoping to get some feedback on how I can speed things up, or any C++ / compilation best practices that I can ...
1
vote
1answer
47 views

Dependency injection thread safety

Is it OK to mix different lifetime of ISerializer and ICacheProvider in this case? I am using Unity DI. In this case, whenever ...
3
votes
2answers
125 views

ArrayBlockingQueue: concurrent put and take

I have implemented an ArrayBlockingQueue (put and take) on the lines of LinkedBlockingQueue i.e using two locks so that my take ...
1
vote
1answer
59 views

Thread safe double buffered cache

I want cache object for one value, which have two expiration limits. One "soft" limit indicating "value is old, but is still valid, but is good time for reload the value". And one "hard" limit ...
5
votes
1answer
45 views

Attempting a fluent API for creating random int arrays

I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with: fluent_arrays.h: ...
2
votes
1answer
41 views

Mergesort using map-reduce, multithreads, buffers and condition variables

I wrote a map reduce program which uses multi threads, bounded buffers, condition variables. It works perfectly for some types of inputs. Is there any way I can improve it? Any help is appreciated! ...
2
votes
2answers
44 views

Rhythmic task controller

The purpose of a rhythmic task controller is to accept a task and execute all the queued tasks in a cycle or "rhythm" defined by the client code. A task returns true or false depending on whether or ...
2
votes
1answer
73 views

Multithreaded for loop

I am trying to multithread a for loop, and this works so far. How can it be improved? Have I done anything incorrectly? The work is broken up into blocks and the ...
-1
votes
1answer
82 views

Using async & await

I've been experimenting with some old code that needs refactoring in places and was testing if there was any improvement to iis threads etc by uploading file asynchronously (Server Side). I'm using ...
2
votes
1answer
30 views

Is it bad practice to have executable code in my channel state object?

I have a CommunicationStateMachine object that's attached to my channels. It keeps track of who's turn it is to speak, how far along the conversation the server and ...
7
votes
2answers
139 views

5 Customers, but only 1 Bank Teller

Recently, as part of an interview, I was given a (seemingly) simple code prompt: To simulate a Bank with 5 customers and one teller, allowing them to deposit to and withdraw from their accounts, but ...
1
vote
1answer
41 views

Submitting callable tasks to a variable number of Threads in a ThreadPool

I am getting into multithreading and I was wondering if the code below is good practice or not. This is one of my first tries at multithreading. Is there a better way of getting the values from the ...
1
vote
0answers
29 views

Asynchronous execution

I needed several classes with methods performing network requests which should be executed asynchronously (with callbacks). To get rid of repetition, I added a mixin and a helper class: ...
3
votes
3answers
173 views

Implementing sequence abstraction

Below is the code that implements sequence abstraction using type abstraction Sequence (in Java): ...
3
votes
0answers
74 views

Timeout watchdog using a standby thread

The simple but generic timeout class to be used watching for network connections, user input, filesystem events, and is intended to have a very simple interface specific to only our use cases (i.e. no ...
5
votes
2answers
125 views

Minimal webserver in C++, second revision

First revision: Minimal webserver in C++ Here's my test question for C++ programmer job: Servers only static content, no cgi Single process, multithreaded 1000 concurrent request at least Valid ...
4
votes
2answers
79 views

ThreadPoolExecutor singleton

I'm trying to build a ThreadPoolExecutor singleton to use it across my app. I'm very new to this concept and after going through Google docs I have created this: ...
7
votes
2answers
124 views

Having sync and async methods by implementing future interface

I need to make a library in which I will have synchronous and asynchronous methods in it and this library will be used by our customer in our company. Some customer will call the ...
0
votes
1answer
60 views

Timers to use various Task(s)

I am developing a C# program, which performs various tasks in parallel threads. I created a Base task and let all tasks derived from this class execute. I just want to know if this a viable approach ...
2
votes
4answers
199 views

Minimal webserver in C++

Here's my test question for C++ programmer job: Servers only static content, no cgi Single process, multithreaded 1000 concurrent request at least Valid http status codes and headers No external ...
4
votes
2answers
55 views

Generic object pool class using Spinlock/Monitor

I've written the following object pool class, and because this is my first encounter with synchronization primitives, I need reinsurance from an expert that this code is safe. I've tested it myself ...
1
vote
0answers
38 views

Simultaneous works with multithreading

I have a case-study for an Android interview. I just wanted to get your opinion before I share the code with the company. There are two fragments: one of them uses a thread-callback structure and the ...
2
votes
0answers
36 views

Asynchronously load and unload a queue

This code is supposed to asynchronously load a queue from a generating function. ...
2
votes
1answer
86 views

SQL Dependency with Broker

I have written a windows service for one of our local servers. This service works like a gem on my local machine, does what it's supposed to (ACCP to exchange db data), but I'm not overly familiar ...
0
votes
1answer
78 views

const_cast of std::mutex in 'get' member

Look particularly at the const_cast in the member getValue(void). Any comments? It seems the best solution me. ...
4
votes
3answers
475 views

Is it ok to use Thread.Sleep and Thread.Interrupt for pausing and resuming Thread like this?

I need to observe a ConcurrentQueue, but to minimize the resources I want to pause the Thread if the Queue is empty and resume it from another Thread if there is a ...
1
vote
1answer
63 views

Thread lock algorithm

I am trying to make a thread lock for a method so that only one thread can run it at a time. Although this is a well known issue and in C# there is the lock keyword to do it. I was trying to do it on ...
1
vote
0answers
27 views

OSGI bundle and threads

I am new to OSGI. I have 10 threads, writing their names to a file. After recording thread sleep random 0..1 sec, this all must be a bundle. Any comments? ...
1
vote
1answer
37 views

My Own ThreadPool implementation

I tried to make a Server using Java with a Thread Pool. Any review is welcome: ...
7
votes
3answers
133 views

Displaying a wait cursor while we're waiting

I come from VB6 where everything is single threaded, so I've never written a lick of multi-threaded code before. I just added a wait cursor to one of our GUI's by stumbling through the docs, but I'm ...
1
vote
0answers
30 views

Using Java's Fork/Join library from Scala

I am a newbie trying to learn some Java and I am reading prof. Dan Grossman's introductory lecture notes on parallel and concurrent algorithms. I wrote a version of a divide-and-conquer algorithm for ...
1
vote
0answers
37 views

Handling output and exit codes of processes

For a large, multi-threaded video processing application, I need to manage various child processes. I need to monitor their stdout and stderr. My key concerns: I should not have any spin loops. I ...
1
vote
1answer
88 views

Thread Safe Objects in CSharp - ConcurrentDictionary

I'm using ConcurrentDictionary to hold the records.. I'm reading files from the local system in parallel, to speed up the process. Sample 1: ...
2
votes
0answers
31 views

Perform additional tests before waiting for an event

I was looking for a way to perform additional tests before waiting for an event: if everything_is_alright(): event.wait() But this is not thread-safe. A ...
4
votes
1answer
94 views

Show dialog only once. Other calls should bring dialog to front, but otherwise not have a result

This code works, as far as I can tell, but there's something that just feels wrong about it. The intended flow is like this: If no dialog is showing Show dialog, return result else Move dialog ...
3
votes
1answer
80 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. ...
7
votes
1answer
105 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 ...
10
votes
2answers
288 views

Get result from UI thread to non-UI thread when using await Task.Run

I have an application where I use Task to run an operation. During the operation, there can be a problem which will need some user interaction (continue or not). I ...
5
votes
1answer
114 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
60 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
66 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
97 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
135 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 ...
4
votes
0answers
115 views

Generic GUI background task runner (Java 8+)

Here is the culprit; headers omitted for brevity, and also, see notes afterwards: ...
1
vote
1answer
85 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
86 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
113 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
58 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 ...