Multi-threading related questions including technique, structure, and safety issues.

learn more… | top users | synonyms (5)

0
votes
2answers
117 views

Lock threads or not lock threads?

I have an application (full-stack) that is used millions of times concurrently. Some vital application properties are managed on the client side (at the time it seemed to be the simplest approach to ...
0
votes
1answer
64 views

ThreadPool.QueueUserWorkItem is this example a valid use case?

I need to send out a batch of reminder emails, never more than 100 emails per batch, using authenticated SMTP. This is happening on a WindowsService (no GUI). The SMTP library we're using raises a ...
0
votes
0answers
25 views

Place of a threading module in a MVP design pattern in Python

I am working on a GUI that displays images, 1 image or many (a video). Some processing is needed before displaying an image. Hence, I would like to do some threading in order to keep the GUI ...
4
votes
2answers
76 views

How to facilitate thread-safe access to large set of shared variables?

I have 2 sets--inputs and outputs--of 70 32-bit integer variables and 70 bools (140 vars altogether). These need to be accessed and modified from 3 threads. What is an appropriate design pattern to ...
18
votes
3answers
19k views

UML Diagrams of Multi-Threaded Applications

For single-threaded applications I like to use class diagrams to get an overview of the architecture of that application. This type of diagram, however, hasn’t been very helpful when trying to ...
2
votes
2answers
222 views

Does it make sense to have a user specified thread limit?

I'm developing a C++14 application and would like to take advantage of the new multithreading features, in particular std::async. I have seen a number of applications which allow the user to specify ...
4
votes
1answer
149 views

Evaluating concurrent application design approaches on Linux

Working on relatively low-speed hardware, I need to grab a snapshot of a rapidly changing datastream and then post-process the snapshot data and save it to disk. I need help with designing the ...
1
vote
2answers
594 views

How can I set a time limit for a game?

I am learning the multi-threading and timer in C# now. But it seems I can't find a good solution. For example, I would like to see how many addition problems that I can solve within 1 min. I would ...
8
votes
3answers
6k views

Looking for a distributed locking pattern

I need to come up with a custom recursive object locking mechanism\pattern for a distributed system in C#. Essentially, I have a multi-node system. Each node has exclusive write permissions over ...
3
votes
1answer
64 views

Is there use case for implementing a callback if a future is returned?

If I have function which returns a future, is there any reason to also include a callback where the callback is simply called right before the future completes? The only advantage I can think of ...
11
votes
1answer
154 views

Do classes in a JRE library support observable and/or asynchronous reads from external/non-JRE assemblies?

How can I implement my cross-platform library (e.g. on JRE) to operate in a thread-safe manner on object references, so that native front-ends on other platforms can observe the object and take ...
2
votes
6answers
231 views

How does immutability remove the need for locks when two threads are trying to update the shared state?

Okay so I read through this: Does immutability entirely eliminate the need for locks in multi-processor programming? And this was the main takeaway for me: Now, what does it get you? ...
1
vote
3answers
320 views

Do I have to fork a server program as an “C” child process in order for correct interprocess communication to take place?

I would like to implement interprocess communication between an Ubuntu Linux 15.10 mono 4.1.2 C# recorder client and Ubuntu Linux 15.10 mono 4.1.2 C# video server using a C++ mutex class and C++ ...
4
votes
3answers
306 views

Queue vs Threads

I'm implementing a data processing software. The software gets form the network thousands of events that must be processed in according to rules. I implemented a multi-thread service, which receives ...
45
votes
8answers
6k views

What are the drawbacks of making a multi-threaded JavaScript runtime implementation? [closed]

I've been working on a multi-threaded JavaScript runtime implementation for the past week. I have a proof of concept made in C++ using JavaScriptCore and boost. The architecture is simple: when the ...
2
votes
1answer
55 views

How to design a dynamic thread allocator

Forgive the title if it isn't correct, I am just not sure what I am trying to design is called. Say I have a number of tasks I want to run, N. Additionally, I have a maximum number of threads I can ...
1
vote
2answers
1k views

Multi-Threaded JavaScript? [closed]

I know, I know -- it isn't possible presently but my question is this: Would it be possible to write a browser plug in for the major browsers that enables true, multi-threaded JavaScript? It just ...
5
votes
2answers
366 views

Why is threading platform-dependent?

I am reading book "Foundations of Qt Development", Chapter 12, and I read that threading is platform-dependent, can someone explain, why? I know how to use threads but that what they said is not so ...
1
vote
2answers
2k views

Multitasking in C#

I would like to use a timer in my C# program with millisecond accuracy to keep a camera in sync with some events and keep shooting a picture every 250ms (or 1/4 sec, or I might adjust it to even ...
0
votes
0answers
78 views

What to use in case of waiting for something that is complete: delegates, events and/or thread

I try to give a concrete example. Create a semaphore for a crossroads. I have two semaphores. I have possibility to set a duration of semaphore 2 minutes, 5 minutes, 10m inutes etc. When one ...
-3
votes
1answer
145 views

C# Share Datatable in Multi-threading

I am beginner in Multi-threading in C# & confuse in current task. My task is to read datatable and display datatable in C# console application using multi threading. I have three threads and one ...
-1
votes
2answers
83 views

Which is better either creating two objects for two threads or one object for two threads?

In the below program, I'm calling method1() of SampleClass from two threads. So, basically I have created two objects for each thread and called the method1(). I have also seen the scenario of ...
4
votes
3answers
156 views

Transitioning from C++ multithreading to Java multithreading

In C++, I've been accustomed to using threads in the following way: #include <iostream> #include <thread> #include <mutex> std::mutex m; int i = 0; void ...
1
vote
1answer
60 views

«Heavy» object initialization: within each thread or outside and then pass it to the threads as parameter?

Let say there is an array of strings, I have to process. I'm using a «heavy» third-part object which gets the string and performs its analysis. In order to optimize a performance, I create a number of ...
2
votes
0answers
53 views

ODBC 3 Multiple Statements vs Multiple Connections

So right now I have a single thread to handle all the requests for the database. Let's say I have 400 requests per second for logins / logouts / other stuff, and 400 requests per second which are only ...
0
votes
0answers
46 views

Merging waitable objects

Lets say you have two (or more) objects from which both allow a thread to wait for an event to occur. Foo.Wait(timeout); Bar.Wait(timeout); The main thread wants to wake up when either of these ...
1
vote
4answers
321 views

What is the ninja performance gap, why is it so large, and how can we overcome it?

According to this abstract: The "Ninja gap" [...] is the performance gap between naively written C/C++ code that is parallelism unaware (often serial) and best-optimized code on modern ...
2
votes
1answer
347 views

Alternatives to Pessimistic Locking in Cluster Applications

I am researching alternatives to database-level pessimistic locking to achieve transaction isolation in a cluster of Java applications going against the same database. Synchronizing concurrent access ...
0
votes
1answer
72 views

Blocking queue for token based synchronization

I'm currently looking for a good solution for the following use-case in C++ (preferably C++11 or C++14): The program is running a server with a TCP connection. Other clients can connect at any time ...
4
votes
4answers
618 views

Generate a random color for every user and keep track of created colors. Every color MUST be different

In my app every user that connects to the server needs to get a random distinct color and I have to keep track of them. About 20 to 30 will be connected in the same time. When a user disconnects, his ...
2
votes
1answer
161 views

How to implement a (truly) global variable in a Rails app

How can I best implement a global counter in a Rails API app? (A central component in a system with several.) Basically I have a transaction id I need to increment and roll over past a maximum value. ...
0
votes
1answer
222 views

How to let multiple threads write on the same file [closed]

I have got a text file called "vholders.txt". I am making multiple threads as you can see here ,those threads work with their own given data and at last they write their own output to the ...
28
votes
8answers
6k views

How do I unit test multi-threaded code? [duplicate]

Are there ways to unit test your multi-threaded code for race conditions and deadlocks? To see if they are performing the way they should be...
0
votes
0answers
109 views

Java Multi-threading

I was solving this question in Java where the user enters a partitioned array. The computer then determines what all elements from that array can be used as pivots. (Pivots are the same pivots that ...
8
votes
6answers
1k views

If I use locks, can my algorithm still be lock-free?

A common definition of lock-free is that at least one process makes progress. 1 If I have a simple data structure such as a queue, protected by a lock, then one process can always make progress, as ...
0
votes
1answer
72 views

Create/destroy multiple threads for animations/light effects

I'm developing a program for the Razer Deathadder and Firefly, I am going to create new light effects for the Firefly. I'm doing this in C# with the Colore library. Now these light effects will be ...
0
votes
0answers
60 views

How to prevent parallel calls to model?

While there is some command running which calls methods on some model, how to prevent concurrent calls for critical places in that model? If multiple requests comes in then they should maintain their ...
3
votes
6answers
220 views

OpenGL, multithreading, and throwing destructors

How do you make an class that properly warns a developer in the future that they've made a mistake somewhere in their implementation that resulted in an object that gets deconstructed in a state that ...
3
votes
3answers
182 views

What is “Split Data Model”, mentioned in the book “Java Concurrency In Practice”?

I'm learning Java multithreading programming by the book "Java Concurrency In Practice". In chapter 9.4.2 Split Data Model, I read this: From the perspective of the GUI, the Swing table model ...
2
votes
3answers
2k views

Design choices when doing multithreading in C++

OK, so, background: I have a little "server" app/module that is written in C++. This is kindof a tunnel application that provides a standardized API via TCP/IP[a] and on the other hand talks to the ...
1
vote
1answer
41 views

Coordinating threads in a multithreaded server

The goal is to develop something similar with a quiz application: there is a server to which players connect. At some point, a game is started. The game consists in asking the players a few multiple ...
0
votes
2answers
47 views

Double-check locking around initialisation which performs a web request

I've just refactored some code that managed a global state cache of values that didn't have locking to use double check locking. Other than moving the initialisation to a single source (the cache was ...
55
votes
15answers
9k views

How important is multithreading in the current software industry? [closed]

I have close to 3 years experience writing web applications in Java using MVC frameworks (like struts). I have never written multithreaded code till now though I have written code for major retail ...
6
votes
1answer
111 views

Python: Control subprocess from calling thread

I am working on a database interface to a MongoDB using Python Eve as an API. The database stores several documents containing parameters and values needed for some calculations. I wrote a Python ...
6
votes
2answers
226 views

Advice for designing API request rate limiter?

I'm in the planning stages of a web application that makes heavy use of data retrieved from a third party's REST API. This data is cached on the server and requested by clients via AJAX. The REST API ...
2
votes
2answers
223 views

Java Thread.sleep() considerations

I've been doing some testing in an app that I've been involved with for the past little while, and it appears as though some of the code we've written is causing a race condition. What's happening is ...
1
vote
2answers
120 views

Thread-safe events — locking on privately held references

I was reading about delegates and events on this webpage to get a better understanding of them and how they relate to each other. While reading, I came across this statement: That goes against ...
3
votes
1answer
132 views

Minimizing lock time (multithreaded app)

I have a web application written in C# which uses external dll written in C++. Communication between clients (web browsers) and a web application is done using SignalR. For communication between web ...
4
votes
2answers
297 views

What is it called when threads are waiting but not deadlocked

The definition of a deadlock is when two or more threads cannot complete their execution because they are mutually blocked and waiting for something from the other thread(s). Is there a similar term ...
1
vote
4answers
289 views

Why is dealing with multiple threads considered difficult? [duplicate]

You can say this is opinion based, but the problem is that everyone's opinion on this issue is same. Even the lead developers say that creating the threads is easy, dealing with them together is ...