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

learn more… | top users | synonyms (5)

0
votes
2answers
357 views

Test a simple multi-player (upto four players) Android game in single developer machine

I'm working on a multi-player Android game (very simple it is that it doesn't have any game-engine used). The game is based on Java Socket. Four devices will connect the game server and a new thread ...
3
votes
1answer
390 views

Is a readonly field in VB.NET thread safe?

Is a readonly field in VB.NET thread safe? For example, see the code below: Class Customer ReadOnly Name As String ReadOnly ZIP As Integer = 98112 Sub New(ByVal Name As String) Me.Name = ...
15
votes
8answers
1k views

Plagued by multithreaded bugs

On my new team that I manage, the majority of our code is platform, TCP socket, and http networking code. All C++. Most of it originated from other developers that have left the team. The current ...
4
votes
2answers
3k views

Why would one ever want to use a synchronized method in Enum?

I stumbled upon this question and a couple of other along the same lines. While we know creation of enum is thread safe and enums are by birth singletons . It kind of confuses me that why would ...
1
vote
3answers
518 views

timers with threads on queue

So I've been asking the wrong questions for the last three days and after searching a lot I think I have an idea of what I need, my question is how to use timers with two threads writing and reading ...
3
votes
4answers
780 views

Testing thread safety

Say you have a function f that is or contains a critical section. How would you unit test that only one thread can run it at once, that it doesn't have race conditions, and that it doesn't cause a ...
1
vote
2answers
635 views

IPC in C under linux

I'm building a messaging solution with the followingsetup: all the messages are saved on a DB, two or more reader processes will read from this DB and send data to other process(es) which will send it ...
4
votes
1answer
668 views

Need to process 2 million 100k messages per second and route them to a particular event, delegate or multicast delegate

I need to process 2 million messages per second (perhaps in a scale out configuration) and route each message to a N delegates or multicast delegates. Question How should I structure my application ...
3
votes
1answer
1k views

How to read from a database, and write to a file asynchronously / non blocking way in Java

I'm trying to modify a serial program that reads from a database, and writes results to a file, this is done in a blocking way and I think we can get performance boost of there is a memory buffer and ...
1
vote
1answer
319 views

Sharing SCTP connection with multiple threads

I have an application that needs to run in SCTP environment, I have a question in sharing the connection among multiple threads for packet receiving only, I've tried with the sctp_sendmsg and it ...
1
vote
4answers
193 views

Resource/Thread Allocation and Deadlock

Here is the question I'm having trouble with: Give the resource graph and determine whether a deadlock state results. Assume that when a thread requests an available or unallocated resource, the ...
4
votes
5answers
316 views

What is the minumum code/operations to have in a separate thread?

I understand that threading is needed to get the maximum performance out of today's multicore processors but starting a thread is rather costly so you can't put every single calculation that can be ...
0
votes
1answer
259 views

Application that provides unique keys to multiple threads

Thanks all for your help before. So, this is what I came up with so far, the requirements are, application has two or more threads and each thread requires a unique session/transaction ID. is the ...
1
vote
3answers
116 views

Application that provides unique keys to multiple processes

Any idea on how to build an application that provides unique keys each time it get called by another process. Calling process isn't my problem here, my problem is how to sync between two(or more) ...
6
votes
4answers
680 views

Command-Query-Separation and multithreading safe interfaces

I like the command query separation pattern (from OOSC / Eiffel - basically you either return a value or you change the state of the class - but not both). This makes reasoning about the class easier ...
1
vote
2answers
262 views

Shared memory multiprocesses

I'm building an multi processes application and I need to save session ID, the sessions ID is 32 bit, and of course it can't be used twice in its lifetime, I'm currently using DB that saves all the ID ...
2
votes
1answer
897 views

C++ Multithreading on Unix

I have two related questions: Are there any good books for multithreading in C++, especially now that C++11 contains multithreading in the standard library? I have the Wrox Programming on Unix book ...
4
votes
4answers
455 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 ...
1
vote
2answers
349 views

x86 segmentation and threading

Is some connection between using x86 segmentation and a possible implementation a thread package? I've been told that usually x86 segmentation is implemented in operating systems these days with an ...
2
votes
2answers
338 views

Is Multithreading Appropriate for Setting up Multiple Windows in the Same Application?

I am currently working with a Qt Application which tries to use multi threading to accomplish two task To Prevent the Main Thread's Event Loop from being blocked To increase computation efficiency ...
5
votes
4answers
5k views

Problems of multiple threads sharing/accessing the same data [closed]

I have been researching into when data is being accessed or shared by multiple threads within Java. And looking into the problems such as: Thread Interference Memory Consistency Deadlock Starvation ...
2
votes
1answer
1k views

What is a reasonable number of threads for a Java program?

In Java (or probably most other languages targeting the JVM) what is a reasonable number of threads to use? Presumably, this will be expressed as a ratio to the number of cores/processors available, ...
13
votes
3answers
2k views

What are the best resources for learning about concurrency and multi-threaded applications?

I realised I have a massive knowledge gap when it comes to multi-threaded applications and concurrent programming. I've covered some basics in the past, but most of it seems to be gone from my mind, ...
7
votes
5answers
3k views

Do threads use virtual memory or real memory?

I was trying to optimize my Linux server to handle 10,000 threads per process while it does just 382 right now. As per this article the following formula is used to find out total possible threads: ...
4
votes
3answers
2k views

Unit of work principle is causing a problem in MVC3 application

I am implementing a website using MVC3, Entity Framework 4.1 and Repositoty pattern, Unit of work principle. But I am facing a big problem while implementing this. I have developed a static ...
8
votes
2answers
3k 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 ...
7
votes
2answers
322 views

where can I find an overview of known “multithreading systems architectures” design patterns? [closed]

Using C#, I have been doing multithreaded development for about 5 years, and consider myself quite proficient (I wrote my own lock-free queue and task parallel framework before Microsoft made TPF). ...
2
votes
3answers
498 views

Sharing buffer between multiple threads part 2

This is a follow up to my previous not answered question, so I try to make it more clear: last question. I have a n-size buffer that is filled up from an external source, it has 2 main methods get() ...
18
votes
2answers
566 views

Why does shared state degrade performance?

I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them ...
4
votes
1answer
737 views

What's the current best practice for C multithreading?

I've been a Java (and PHP) developer for most of my life, but will need to use C for my next project. I remember some basic stuff we did back in school with fork, pthread, semaphores, etc. but I'm not ...
5
votes
2answers
1k views

How to parallelize a sequential algorithm?

What thought process should one follow to convert a sequential algorithm to a parallel one ? Are there any specific code pattern that can be parallelized. Some patterns that I normally use are: ...
4
votes
2answers
248 views

Decoupling Threads

It's not uncommon to hear of decoupling the UI from program logic, or database design/access from program logic...or even program logic from itself. However, I've never heard of an approach to ...
3
votes
5answers
3k views

Sharing buffer between multiple threads

I had a job process that was executing a lot of IO to read and write temporary files. Now I want to (need to) reduce the quantity of IO executions. So I want to create a sort of circular buffer ...
7
votes
9answers
3k views

Multithreaded file copy

There is an utility we have which is used to upload files (and perform other operations on the file) to a network shared location. The file size tends to vary from a few mb to 500 mb. A suggestion has ...
4
votes
1answer
460 views

Is there a formula to figure out the total execution time of sequential asyncronous processes?

I have a set of steps that need to run sequentially over a list of data. However each step only operates on a single piece of data at a time. Because of this, I can run the steps asynchronously. For ...
3
votes
1answer
252 views

What are the relative merits for implementing an Erlang-style “Continuation” pattern in C#

What are the relative merits (or demerits) for implementing an Erlang-style "Continuation" pattern in C#. I'm working on a project that has a large number of Lowest priority threads and I'm wondering ...
14
votes
3answers
8k 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
1answer
182 views

Threading models when talking to hardware devices

When writing an interface to hardware over a communication bus, communications timing can sometimes be critical to the operation of a device. As such, it is common for developers to spin up new ...
19
votes
3answers
4k views

Why not Green Threads?

Whilst I know questions on this have been covered already (e.g. http://stackoverflow.com/questions/5713142/green-threads-vs-non-green-threads), I don't feel like I've got a satisfactory answer. The ...
3
votes
2answers
265 views

Massive vehicular network simulator

I am interested in making a vehicular network simulator (vehicular network as in vehicles can be equipped with radios and when they come in range they can talk with each other). I want to be able to ...
5
votes
2answers
1k views

How to do thread management in C++?

We use pthread for thread management in C based systems. pthread is in general compilable by C++ compiler (like g++). However, what are the better ways of abstractions for threads in C++? Also, for ...
4
votes
1answer
395 views

Producer-consumer pattern with consumer restrictions

I have a processing problem that I am thinking is a classic producer-consumer problem with the two added wrinkles that there may be a variable number of producers and there is the restriction that no ...
10
votes
2answers
670 views

Is my description of the actor model right?

If I understood, the actor model is just like the object model, but with a few differences: EVERY object spawns it's own separate thread and its not a problem even when you have thousands of ...
10
votes
1answer
264 views

Drawing thread interaction

I'd like to draw (pen and pencils) threads interaction in a UML(-like) notation. I don't insist on UML, anything that is obvious to the reader should do. I started with sequence diagrams, but I don't ...
15
votes
3answers
6k views

How will C# 5 async support help UI thread synchronization issues?

I heard somewhere that C# 5 async-await will be so awesome that you will not have to worry about doing this: if (InvokeRequired) { BeginInvoke(...); return; } // do your stuff here It looks ...
6
votes
2answers
618 views

Thread class design?

I have a method like this in my UI code: void MyDialog::OnCommandSaveData() { std::list<MyClass*> objects; service_->GetAll(objects); dataService_->SaveObjects(objects); ...
11
votes
6answers
2k views

Solutions to C# 5 async re-entrancy

So, something's been bugging me about the new async support in C# 5: The user presses a button which starts an async operation. The call returns immediately and the message pump starts running again ...
5
votes
2answers
1k views

Is there such a thing as too much asynchronous code?

I am at the moment messing around with clients and servers in C# winforms and I'm trying to implement it all asynchronously. However, I'm beginning to wonder, should I use asynchronous code for ...
19
votes
10answers
6k views

State machines vs threads

Alan Cox once said "A Computer is a state machine. Threads are for people who can't program state machines". Since asking Alan directly is not an option for humble me, I'd rather ask here: how does ...
4
votes
2answers
394 views

Multithreaded Programming? [closed]

Recently I've finished learning about multithreaded programming on single shared objects, but was curious about how different things would be in order to successfully program on multiple shared ...