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)

6
votes
1answer
84 views

Thread-safe memoizer

I have searched around but I was not able to find a complete implementation of the memoize pattern in a multithreaded context. It's the first time playing with thread synchronization. The code seems ...
1
vote
0answers
30 views

A Note class which plays a note and stops it after specific period of time

Update: The original post is below. It seems that I misunderstood the difference between Dispose() and garbage collection. So, the reference of midi_output will ...
2
votes
0answers
35 views

Refreshing customer list periodically in the background

I have a method RefreshCustomersInternal that refreshes customer data from a server and returns a Task. Since this process is ...
3
votes
2answers
48 views

Resource caching in Java with soft references

I'd like to cache some heavy resources locally. The goal of this implementation is to have be able to load resources for an unknown amount of time and then keep them in memory and finally evict them ...
-3
votes
0answers
90 views

What is the fastest way to make sure a post action results in a database addition? [closed]

I am trying to understand the performance of my mobile service in Azure but it is not entirely clear to me how I can improve the performance. The idea behind the following code is that an API call ...
10
votes
5answers
180 views

Word frequency in a large text file

I've am trying to read a large text file and output the distinct words in it along with it's count. I've tried a couple of attempts so far, and this is by far the fastest solution I have come up with. ...
2
votes
1answer
51 views

Custom Session Pool

We use a student information system called Colleague that is developed by Ellucian. As far as I can tell, the system does not use any sort of session pool so rapidly opening and closing connections ...
2
votes
1answer
41 views

ThreadPool based on ASIO, using a particle emitter

This code exists in my home repo and in general nobody else has really touched it. Living in such a vacuum has left me kind of uncertain of the actual code quality and correctness which is why I am ...
4
votes
1answer
56 views

MailQueue - follow up

Follow up of this question. Things altered: Put logging (debug level) for creating and starting thread. A separate thread for starting the different threads. Locking object and synchronise for ...
3
votes
0answers
75 views

Microsoft TPL DataFlow Thread Safety

From the MSDN site it mentions that all the public static members are thread safe. I have the below scenario and needed some advice I have a simple interface ...
4
votes
1answer
54 views

Implementing pthread barrier for Mac OS/X

I have written this little thingie to fix a problem of missing pthread_barrier_t in Mac OS/X pthreads. Are there any issues with this code? The header: ...
5
votes
2answers
88 views

Producer consumer water cooler example

I have written a water cooler example in which the consumer drinks from the water cooler until it's empty and when it gets empty the producer fills it up. The consumers wait until it's filled up and ...
1
vote
1answer
66 views

C++11 Thread Pool

I've been using a thread pool that I wrote using Windows threads for a while and I've decided to update it to use std::threads. I'm looking for some feedback on ...
4
votes
2answers
83 views

Portable C++98 thread class akin to std::thread

I want a homegrown version of C++11's std::thread. My motivation is to avoid manual memory management of the arguments passed to the thread function. I'm restricted ...
5
votes
2answers
99 views

MailQueue implementation with auto start - stop

Previous question was a little portion of the mailQueue. I finished the MailQueue, which has the ability to start and stop ...
1
vote
1answer
62 views

C++ class template for notification management

Recently, I found myself frequently writing notification managing facilities. That is, one can register as a receiver by providing a callback, and another can send a notification to all registrants by ...
1
vote
2answers
102 views

Check before proceeding if the task in BackgroundWorker has completed

I have a Login Form (which has a label that will show status of background process, username and password text boxes, Login and Cancel buttons) along with that I have a background worker to do some ...
6
votes
0answers
83 views

C++ concurrency library

I started a C++11 library of concurrency primitives in order to study and compare their performance; provide high-quality implementation of those to use in my projects. Its main target platform is ...
3
votes
0answers
30 views

Processing 2 Sketch

I'm working on a processing sketch here. Main sketch: ...
4
votes
1answer
127 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
46 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
69 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
151 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
70 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
46 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
47 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
46 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
97 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
114 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
31 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
167 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
45 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
39 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
106 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
133 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
113 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
130 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
65 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
206 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
68 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
41 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
1answer
49 views

Asynchronously load and unload a queue

This code is supposed to asynchronously load a queue from a generating function. ...
2
votes
1answer
112 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
96 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. ...
5
votes
3answers
579 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 ...
0
votes
1answer
83 views

Thread lock algorithm [closed]

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
32 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
42 views

My Own ThreadPool implementation

I tried to make a Server using Java with a Thread Pool. Any review is welcome: ...
7
votes
3answers
165 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 ...