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

learn more… | top users | synonyms (5)

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 ...
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 ...
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
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 ...
55
votes
15answers
10k 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
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 ...
6
votes
2answers
255 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
259 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 ...
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 ...
4
votes
2answers
298 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
295 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 ...
1
vote
0answers
61 views

When do you need precision with thread execution timing and how do you do it with Java? [closed]

(Under software architecture/design) I'm not sure how my question could be subjective but the message next to the title suggests that it is. I hope I'm not violating the rules here. Under what ...
1
vote
0answers
30 views

Push instead of pull on a list that might change due to a command in addition to events? [closed]

I need to show a refreshable/searchable list of items and update/add-to it whenever an event is published. How do I make sure no events are lost while refreshing/searching is happening? Some sort of ...
1
vote
0answers
96 views

Running simulations in parallel, managing each separately [closed]

Let me preface this by admitting that I am a novice - this is the first real project I am doing outside of a class. I am running a single-threaded C++ simulation several hundred times (i.e. I have ...
-1
votes
1answer
79 views

Approaches to Concurrency [closed]

I’ve been doing some research on the various approaches to concurrency, and I’ve ended up with the following taxonomy: Manual thread based concurrency with locks Asynchronous dispatch queues and ...
0
votes
1answer
289 views

Converting from List<Object> to Array with threads

I have a large (>500.000) list of Objects and I want to convert it to a multidimensional array. Until now I am doing this using a for loop, but after some measurements I identified that this is a ...
0
votes
1answer
202 views

Android Service vs Simple class with thread for network access [duplicate]

I am in quite a dilemma about how to solve my problem regarding network access. I checked this question but it does not really gives a solution for my problem. All of my REST based requests are ...
3
votes
3answers
571 views

Why (most?) retro computer emulators are single threaded?

All real computer hardware works in parallel. So why most emulators of retro systems (like NES) are single threaded (or I'm not right?)? You have main loop and you counting CPU cycles and after ...
2
votes
4answers
170 views

Is it a good idea to make method behavior depend on the calling thread?

I want to subclass a 3rd party class, in order to make it thread-safe. I have a good idea of how to implement this, but there is a problem: the superclass has a property, which affects the behaviour ...
1
vote
1answer
2k views

Which child process will inherit threads of parent process?

What happens when one process has child threads and a child process, will child process inherit all child threads of parent process? Assume OS is Linux. Let it be Java Threading model.
5
votes
1answer
124 views

Pthread scheduling (System and Process)

I've read the operating system concepts 8th edition written by abraham silberschatz. However, I don't understand Pthread Scheduling. Thread-library schedules user-level-threads on LWP(Lightweight ...
1
vote
2answers
126 views

Don't quite understand check and set in concurrency

I don't entirely understand check and set behaviour.. here is an example: public static void main(String[] args) { List<String> list = Collections.synchronizedList(new ArrayList<>...
4
votes
1answer
126 views

Threads: the difference of concurrency between many-to-one model and one-to-one model

I am studying "Threads" part with a textbook, Operating system concepts written by Abraham Silberschatz, Peter, Greg. First, I'm going to say something in the textbook related to my question, and ...
1
vote
0answers
102 views

Better choice of Queue then a ConcurrentLinkedQueue if I have low number of threads in Java

I have two threads, one that is reading messages from the web and putting them into some sort of a queue. The other is suppose to read it. I looked into a ConcurrentLinkedQueue and it looks good for ...
23
votes
3answers
9k views

Why is multithreading often preferred for improving performance?

I have a question, it's about why programmers seems to love concurrency and multi-threaded programs in general. I'm considering 2 main approaches here: an async approach basically based on signals, ...
5
votes
1answer
167 views

How can I best test a multithreaded C producer-consumer program? [closed]

How does one best write tests for a multi-threaded producer-consumer C program? I know GDB can be used to debug threads, but I believe GDB also stops the thread currently being debugged while other ...
1
vote
0answers
108 views

Terminology - Difference between thread and process and how they manage DB connections

I've been working more with concurrency in Ruby recently, and I keep seeing various articles using "threads" and "process" interchangeably. What are the actual definitions of these terms? Is a ...
1
vote
0answers
45 views

Cost of cache coherency/sharing data across multiple cores?

If I have two CPU cores, one is writing a particular cache line and the other core wishes to Read Write the same cache line, what are the costs (in cycles) for doing so? I am a little unsure ...
3
votes
1answer
104 views

Eliminating thread affinity requirements when converting an STA COM object into an MTA COM object

Suppose I need to convert an STA COM object into an MTA object. Single threaded apartments guarantee not just that only one thread will call the object at a time, but that it's always the same thread ...
9
votes
3answers
3k views

Parallelism implies concurrency but not the other way round right?

I often read that parallelism and concurrency are different things. Very often the answerers/commenters go as far as writing that they're two entirely different things. Yet in my view they're related ...
0
votes
3answers
2k views

Is it ok to restart a BackgroundWorker inside its Completed event

I want a background worker to continue running and occasionally update the user interface. My first idea was to use a BackgroundWorker and in its completed event just fire it up again. Is using a ...
2
votes
1answer
2k views

Thread.State BLOCKED vs WAITING

What is difference between the BLOCKED and the WAITING states of a thread. As per JAVA code comments /** * Thread state for a thread blocked waiting for a monitor lock. * A thread in ...
0
votes
2answers
225 views

What happens to lock's state and methods when a thread acquires a lock?

Assume I have following class class Student{ void method1(){ // Do Something } void method2(){ // Do Something } } And the object of this class is used as monitor in ...
35
votes
4answers
4k views

Why is it the caller's responsibility to ensure thread safety in GUI programming?

I have seen, in many places, that it is canonical wisdom1 that it is the responsibility of the caller to ensure you are on the UI thread when updating UI components (specifically, in Java Swing, that ...
-3
votes
2answers
2k views

Difference between daemon and child thread? [closed]

As per my knowledge daemon thread is a thread that runs in background(low priority thread) and also a child thread runs in the background when the parent thread runs foreground so where does the ...
0
votes
1answer
174 views

Thread synchronization for multiple threads accessing a message stream

My project has a single message stream (communicating with an external device) which is accessed via multiple client threads. The workflow is: There is a thread (the "messaging thread") which reads ...
1
vote
1answer
1k views

C#/.NET multithreaded application design

The application to be designed serves as a bridge between two different systems. One natively speaks TCP (RS232 actually, but there's a COM->ETH server in the line of communication) - the other one is ...
4
votes
3answers
2k views

Const means Thread-safe? [closed]

I was put onto this video: http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-blank-and-blank By http://codereview.stackexchange.com/users/39810/glampert Because I asked ...
4
votes
2answers
107 views

Preemptive scheduling with “do not disturb”

In this answer about threading it is said: In preemptive scheduling, a thread can be interrupted at any time, either by a timer interrupt or any other interrupt or during a system call. The part ...
4
votes
1answer
531 views

C# async/await: Pedantry vs. the Debugger

I'm playing around with async and await, and they seem pretty intuitive, but some of the things I'm reading about these keywords doesn't make sense to me. In fact, some of it seems to me to be flat-...
2
votes
1answer
189 views

Multithreading with triple buffer, do I have to do the waiting for the condition variable?

I have a triple buffer implementation that is often used in threads in such a way that when new data is expected, there's always a WaitData(n) function called on the buffer (A condition variable's ...
50
votes
16answers
4k views

Should I take care of race conditions which almost certainly has no chance of occuring?

Let's consider something like a GUI application where main thread is updating the UI almost instantaneously, and some other thread is polling data over the network or something that is guaranteed to ...
1
vote
1answer
500 views

Performance of sharing single object with multiple threads in Java

In Java, if I create an object that has a method to do something, and I pass that object to multiple threads which call the method, is there a performance difference from creating an individual ...
1
vote
0answers
192 views

Threading strategies for a webservice implementation

If I am building a webservice/Web API for servicing requests, there are 2 threading strategies I can think of. I will explain this in terms of Java (though the question may be relevant for any other ...
3
votes
1answer
390 views

How do I prevent a long running SQL query from looking stuck?

If I had a method like: private void someMethod() { runSqlQueryA(); runSqlQueryB(); runSqlQueryC(); } My understanding is this method will be one thread. In weblogic, the thread will ...
1
vote
1answer
332 views

Behaviour of Thread sleep in a single core processor machine?

I'm trying to understand how threading works when using a single core, not hyper-threaded processor. I have two identical console applications running on a machine that has one core CPU and 1 GB of ...
0
votes
2answers
122 views

Built-in the separate thread execution inside of the method or wrap the method by the thread

Let assume, I have some resource and time-consuming code, which I want to arrange as a separate method. In order to optimize the performance, this code should be executed in the separate thread. Now ...