Multithreading 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)

3
votes
1answer
43 views

Using Task<T> and actions for simple threading?

My question is regarding a rather inelegant solution to a problem that I came up with a while ago. I was making a Winform Application to access active directory among other things and needed to ...
2
votes
0answers
35 views

Low-lock Multi-threading Implementation

I'm designing in my spare time a game engine (for fun, not so much for profit, haha). I wanted to design the 'core pipeline' as efficiently as possible. Having a quad-core CPU, I decided to take ...
3
votes
2answers
67 views

Python Port Scanner

This is only my third Python script. Be brutal with me. Any tips, tricks, best practices, or better usages would be great! import socket from concurrent.futures import ThreadPoolExecutor THREADS = ...
2
votes
1answer
47 views

1 Producer, N Consumers working in parallel, each doing ~1/nth of a task

I am not wondering about error checking (will add that soon). I would like to know about correctness, efficiency and simplicity? #include <pthread.h> #include <stdio.h> #include ...
1
vote
0answers
52 views

Multi producer/consumers lockfree list

As per similar question Multi producer/consumers lockfree stack, following a lockfree list implementation. Note that this list is pre-defined maximum set of elements which can be inserted (N argument ...
0
votes
1answer
78 views

Is such style good for using unsafe features in C#? [closed]

Is such style good for using unsafe features in C#? Or, why is it bad to develop such code? #define LOLZ using System; using System.Threading; using System.Runtime.InteropServices; unsafe struct ...
6
votes
1answer
59 views

Client server application for file transfer

I have an application for transferring files from clients to a server. A client opens, transfers a file to the server and closes. The server is open and may receive multiple files. Also, when ...
2
votes
1answer
46 views

Sleep and background wakeup system

I'm looking for code review of part of my replacement of timeout() project. Namely, feedback on SleeperNotifier class: https://github.com/ledestin/frugal_timeout/blob/master/lib/frugal_timeout.rb#L125 ...
4
votes
1answer
79 views

simple ThreadPool implementations

I would like to ask you for a code review of my c++11 Thread Pool implementation. Your constructive criticism is welcome! Could you give me some ideas how to extend it? The main idea is to ...
4
votes
2answers
77 views

Making an array whose elements are defined by a struct [closed]

This might be a basic question for C. I'm making a struct called check_t and I want to make an array whose elements are of type check_t. This array is called enqueued. The struct check_t contains an ...
2
votes
1answer
77 views

Multithreaded horse race simulation

I'm just starting to get along with threads in Java and I need some code review, about interfaces, classes, managing threads, correct writing, secure threads, exposed objects etc. Horse-Race ...
6
votes
1answer
171 views

Thread pool on C++11

The class supplies a simple thread pool that uses the thread class from C++11. When I schedule the job, I pass two std::function objects that the pool will execute: the first function is the real ...
2
votes
0answers
42 views

Python app-level document/record locking (eg. for MongoDB)

Introduction MongoDB does not provide means to lock a document (like SELECT FOR UPDATE in RDBMS). There is recommended approach to Isolate Sequence of Operations, which is sometimes called ...
2
votes
1answer
73 views

Pausing and Manipulating Data in a Process with a GUI [closed]

I think I have fixed the issues which caused this program to not be functional. Now I believe the design of my code is somewhat bad and may be causing problems with the number of processes that are ...
5
votes
1answer
48 views

Listening for values changed by the memory

I'm fetching some values from the memory. I would like to create some custom events that I can listen to for each value. Since there are no existing events regarding memory changes, I've decided to go ...
4
votes
1answer
140 views

Multi producer/consumers lockfree stack

Can you please take a look at the following x86-64 C++ code which should implement a multi consumer/produce lockfree stack? Do you think I have missed anything? namespace lockfree { // NOTE: this ...
2
votes
1answer
139 views

Thread safe enqueue and dequeue method in Queue

As an exercise, I have implemented a linked queue whose enqueue and dequeue methods are synchronized. There is a Producer thread which keeps inserting elements into the queue as long as there are less ...
2
votes
0answers
47 views

Is throughput performance of lockfree stack in line with expectations?

As per subject, following a relatively simple C++/gcc/x86-64 implementation of a lockfree stack. I believe the ABA issue should have been fixed in the pop method too; following code for reference. Is ...
1
vote
2answers
92 views

Is this the right way to thread-protect an object?

I wrote an FAQ on a third-party website which pertains to thread-protecting objects in Delphi. What I'd like to know is if this thread-protection approach is accurate, or if I should change anything ...
2
votes
1answer
63 views

Script for starting a rails app, with some peculiarities

I wanted to write a script, which starts a rails app, and opens it in the browser. I'm trying to implement this in a peculiar way though - I expect two things: the script must wait until the server ...
2
votes
1answer
360 views

Producer/Consumer in C#

Is the following implementation correct? private int _count = 1000; private Queue<string> _myQueue = new Queue<string>(); private static object _door = new object(); public void ...
1
vote
1answer
63 views

Background image loader AsyncTask

Usually, AsyncTasks are meant to be one-shot, i.e. you start it, it fetches some data, displays the result and dies. However, I'm now using a long-running AsyncTask to load images as the need arises. ...
6
votes
2answers
214 views

Is this code thread-safe?

EDIT: The full source code in question can be found here. Is this code reasonably safe against dead/livelocks, and if not, how can I fix it? I know processes are usually recommended over threads ...
6
votes
3answers
268 views

Multithreading C++ loop

I've made a small skeleton for a larger project that will include cross-platform multithreading (by using Boost) and thread-safe random numbers (by using GNU scientific libraries and mutexes). My ...
1
vote
2answers
121 views

Producer-Consumer using low level synchronization

I saw a tutorial from a site where it showed the use of ArrayBlockingQueue as a thread-safe concurrent data-structure . Just for learning purposes , i tried to build something similar using ...
1
vote
3answers
87 views

Optimize calculation of distances between pairs of points

I was trying to solve a challenge. The execution time should not exceed 5s, but for some value my code took longer. I want to know if I can optimize my code for performance. public class Solution { ...
3
votes
1answer
71 views

Synchronization-Thread with Server every 5 secs

I have a server-client environment, where the client connects and synchronizes data with the server every 5 second. For synchronizing I use a background thread on the client which works fine, but on ...
2
votes
1answer
196 views

Basic, single-threaded, implementation of SynchronizationContext

I am trying to write a SynchronizationContext in C# that represents a message queue, to be pumped from a main loop. Edit: I see that I have forgotten to say - I need the message loop executions to be ...
3
votes
2answers
90 views

Java Bouncing Ball Review

Just looking for some help reviewing/refactoring. For example, could the classes random/vertical be refactored into 1 class instead of 2? BouncingBalls.java import java.awt.BorderLayout; import ...
1
vote
3answers
93 views

Code Improvement/Modification [closed]

Typical bouncing ball program. Looking to improve and perhaps add to the program. For example, is it possible to be able to click on a ball and have it pause? import java.awt.BorderLayout; import ...
4
votes
2answers
169 views

do->while with waiting?

I have the following code in my C#/.net 4.5 app: bool waiting = false; do { if (waiting) Thread.Sleep(10); var ftdiStatus = FtdiDevice.FtdiDevice.Instance.GetRxBytesWaiting(ref ...
1
vote
1answer
101 views

Calling different bundles in parallel using ExecutorService

I am working on a project in which I will be having different Bundles. Let's take an example, Suppose I have 5 Bundles and each of those bundles will have a method name process. Below are the things, ...
2
votes
1answer
91 views

is this producer-consumer implementation correct?

I want to ensure that, as much as possible given my skill level, that I'm using relevant patterns correctly and following naming conventions. This is a controller for a poor-mans MUD client using ...
3
votes
1answer
187 views

Unit test an ExecutorService in a deamon

To execute tasks sequentially with a timeout I use ExecutorService.submit() and Future.get(). As I don't want to block calling clients, I implement producer–consumer pattern with a queue into a Thread ...
1
vote
0answers
98 views

Simple multithreading and synchronization problems in MFC

I use a worker thread for some data processing in my MFC project. In the thread-controlling function, it needs to use some parameters (declared as member variables) to the data-processing. I use a ...
0
votes
1answer
345 views

Single Producer, Multiple consumer issue [closed]

I'm writing a simple producer/consumer pattern using BlockingQueue. Here are the classes Message class used as Wrapper around actual message and type. Type is later used poison pill. public class ...
1
vote
1answer
89 views

Better way to use a Condition (CancellationToken)

Is there a better way to write this, as i am using the condition of the Cancellation Token to tell if it should use a byte[] from another thread or not. SharpDX.Windows.RenderLoop.Run(form, ...
0
votes
1answer
83 views

Using Threads, Is this a good way?

So, i have 2 threads, one listen on TCP, other Render in a loop. So, to Start and End, i have this code: private void checkBox1_CheckedChanged(object sender, EventArgs e) { try ...
3
votes
1answer
87 views

Polling multiple servers

I have an application which polls a bunch of servers every few minutes. To do this, it spawns one thread per server to poll (15 servers) and writes back the data to an object: import requests import ...
2
votes
1answer
58 views

Is this a good way to syncronize my Threads?

After getting much improvement, it´s still one issue that concerns me. And that is the sync between my 2 threads. I use AutoResetEvent, but sadly, it has some delay with it, and would love to use ...
3
votes
1answer
150 views

Searching through a huge set with threads

I wrote a class that finds values in a huge search volume. I have a pretty strong feeling that my code is not good and would like to get your opinion on it. My experience with C++11 threading is very ...
3
votes
2answers
166 views

Volatile boolean to prevent Deadlock (Is Lock better than Volatile)

I wrote this code to overcome the deadlock condition described in this Oracle Tutorial http://docs.oracle.com/javase/tutorial/essential/concurrency/deadlock.html Summary of Problem:Alphonse and Gary ...
2
votes
1answer
103 views

Threading in Java

I wrote this small project to practice threading in Java. At first, I planned to do it like this. But later, someone pointed me to Executor. Then, I found this tutorial and followed it through. Here ...
4
votes
0answers
55 views

1 producer, n consumer with QThread

I am new to C++ and to threading, so I'm sorry if my code is bad. I'm here to get it better and to learn. Any kind of advice (both on C++ style, on Qt usage, or on threading handling) is welcome. ...
2
votes
1answer
143 views

Proper cleanup in multithreaded client/server code

For a university project I'm trying to build a system that has a general architecture of: Client app <=====> Client library < - - > Server library <=====> Server app I'm trying to make the ...
1
vote
1answer
526 views

How to further improve this Ramer-Douglas-Peucker algorithm in C#

Ramer-Douglas-Peucker is a great algorithm for reducing the number of samples in a given trace, and also for keeping its general shape (as much as he can). I have a trace with 32.000.000 samples, and ...
1
vote
1answer
32 views

Efficient way of printing a range of numbers using configurable worker threads

I have written a code to print a range of numbers using multi-threaded programming , the code takes in the number of threads to spawn as input .The code is working fine and giving the expected results ...
0
votes
0answers
75 views

Improving class for parallelising parts of main codebase

This is a class I wrote for parallelising certain parts of my main codebase. How could this code be improved in terms of making it shorter, more secure, and more efficient? using System; using ...
3
votes
3answers
129 views

Does this Actor implementation has synchronization problems?

As a part of a job test, I wrote following implementation of the Actor execution model: import java.util.LinkedList; import java.util.Queue; import java.util.concurrent.Executor; public abstract ...
2
votes
1answer
316 views

Generating random numbers in multiple threads

I'm trying to learn how to use threads to generate lots of random numbers. In particular, I'd like know: Is the following code thread safe? (I think the histogram class is the only one that requires ...