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

learn more… | top users | synonyms (5)

-1
votes
1answer
21 views

What are the pros and cons of using these Multithreading Models in a Client/Server Architecture

In my classes of parallel programming the teacher mentioned three models, dynamic thread creation (create threads according to demand), thread pool (create a fixed amount of threads) and mixed or ...
-3
votes
0answers
23 views

How to find which module of a windows service is leaking memory [on hold]

I have a windows service which host about 7 or at sub services. There are lots of periodical work going on. Threads sleep are called from 5 seconds to 3 minutes for different services. Recently what ...
0
votes
1answer
109 views

Using database connection on multiple threads

let's say I have a database connection in the class Database which offers the following public methods public synchronized void open() {} public synchronized void close() {} public synchronized void ...
-1
votes
1answer
142 views

How to signal a loop to continue the execution instead of using sleep

I am trying to create a thread that will sit and wait to detect new objects in a vector (the queue). Using a loop will crush the resources on the given machine, so I am trying to figure out how I can ...
-2
votes
0answers
55 views

Python web crawler [closed]

I wrote a python web crawler #!/usr/bin/python import threading import urllib import Queue from bs4 import BeautifulSoup import sys import time import signal visited_urls = [] crawl_lock = ...
1
vote
1answer
66 views

Collect and prcess data from multiple threads in Java

There is a Java program that reads a list of orders and for each order starts a thread that receives data from SQL and prints the list of items in a given order to an order_name.html. I want to write ...
6
votes
2answers
148 views

Do compilers utilize multithreading for faster compile times?

If I remember my compilers course correctly, the typical compiler has the following simplified outline: A lexical analyzer scans (or calls some scanning function) the source code character-by-...
3
votes
1answer
164 views

Potential legal issues with lock-free / wait-free structures / algorithms

While researching the subject matter - lock-free and wait-free data structures - I'm seeing a worrying amount of mention of patents with this area. I've hobby-researched compression algorithms years ...
0
votes
2answers
74 views

Why a thread uses a stack in a context switch?

Correct me if I'm wrong, but if I have an operating system that makes a context switch, then that context switch is in practice a switch from one thread to another, where one thread was running one ...
3
votes
0answers
69 views

Monitor.Enter() when a thread is of highest priority

Background Okay, so let's say I have some high priority (ThreadPriority.Highest) thread t which needs to enter a critical region in order to consume some data. I will use the following code snippet ...
1
vote
2answers
196 views

multi-threading performance when CPU is maxed out

I've noticed my software severely degrades when the # of threads is substantially increased. What I mean is that when I limit the # of threads, the performance is much better than when I just let ...
4
votes
2answers
83 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 ...
3
votes
1answer
71 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 ...
2
votes
6answers
240 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
331 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++ ...
2
votes
1answer
57 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 ...
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 ...
0
votes
0answers
83 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 ...
6
votes
2answers
372 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 ...
-3
votes
1answer
180 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
87 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 ...
0
votes
2answers
122 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 ...
1
vote
1answer
63 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 ...
4
votes
3answers
158 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 makeACallFromPhoneBooth()...
2
votes
0answers
60 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 ...
4
votes
3answers
322 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 ...
0
votes
0answers
48 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 ...
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
667 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 ...
1
vote
4answers
332 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 multi-...
3
votes
1answer
173 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
302 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 vholders....
0
votes
0answers
113 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 ...
0
votes
1answer
78 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 ...
2
votes
2answers
227 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 ...
0
votes
1answer
80 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
61 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
3answers
192 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 ...
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 ...
3
votes
6answers
234 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 ...
0
votes
2answers
49 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 ...
6
votes
2answers
252 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 ...
6
votes
1answer
116 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 ...
2
votes
2answers
254 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
122 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 ...
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
294 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 ...
10
votes
2answers
435 views

Why do programmers define programming models to replace C/POSIX for parallelism?

Providers of new computer architectures regularly try to introduce new programming models, e.g. recently CUDA/OpenCL for GPGPUs, and displace C/POSIX as the control interface to platform ...
3
votes
1answer
135 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 ...