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

learn more… | top users | synonyms (3)

0
votes
0answers
101 views

Why user threads are mapped to Kernel threads

Since user threads are mapped to kernel threads, why don't we create all threads as kernel threads that is a process with zero user thread. Doesn't mapping of user thread to kernel thread create ...
3
votes
1answer
928 views

Database design/relationship for threading messages

What's the database design or business logic for creating an app for messaging between users? I am having difficulties with choosing how to approach the relationship between each Conversation of User ...
2
votes
2answers
1k views

How Stack and Heap is allocated for threads under the same process in Windows?

Stack for different thread is different.but what about Heap. If Heap is different for different threads, then how they share objects?
2
votes
1answer
213 views

Transactional Memory vs Mutex and Locks

Just found out that Intel processors now have Transactional Memory support !!!! I learned about Transactional operations in my dB/OS class, it is a very simple concept: entire operation is executed or ...
14
votes
1answer
758 views

How can I tell if I am overusing multi-threading?

I currently feel like I am over-using multi-threading. I have 3 types of data, A, B and C. Each A can be converted to multiple Bs and each B can be converted to multiple Cs. I am only interested in ...
1
vote
1answer
124 views

Optimising news fetching

I have a web scraper for scraping news from different sources in wp7. My current appraoch for doing this is: load newspapers information from xml file. go to the specified sections and fetch the ...
0
votes
2answers
174 views

Why would Java app make RPC call to itself?

I am working with a multithreaded homegrown multi-module app in my new job. We use the the Thrift protocol to communicate RPC calls between different stand-alone applications in a distributed system. ...
1
vote
0answers
105 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 ...
2
votes
3answers
208 views

How do I limit the resources available to a program?

I'm delving into multi-threaded programming with Java, but I'm finding it hard to test my program for bugs. My computer simply has too many resources and cores, making it hard to see how my program ...
1
vote
0answers
436 views

Java UDP Multithread Server

I have multiple threads. Each thread receives data and sends to client an acknowledge packet. Each thread takes aprox. 531ms from start to finish. While capturing packets with wireshark. I was ...
0
votes
1answer
678 views

C# Design for SQL connection and commands

Currently I'm working on system that works with database, and I would like to have it done elegant way. So I have abstracted DBConnection into one class, DBCommands into another class. (DBCommands : ...
1
vote
1answer
795 views

c++ web with nginx - Do I have to worry about thread safety?

I am currently developing my website with c++. I know that nginx handles connections with multiple threads to provide high performance. And not all c++ code is thread safe. What's the relationship ...
3
votes
1answer
123 views

Do you have to ban atomics to get good tool support for race detectors?

It seems that Helgrind treats atomics the same way as normal read/write operations. So, using atomics will result in lots of false positives. I don't know exactly how ThreadSanitizer deals with ...
6
votes
1answer
1k views

Sleeping Barber Problem (with multiple barbers)

The Sleeping Barber Problem is a classical synchronization problem that many of you may be familiar with or at least heard of. It's based on the premise that a barber (a thread) sleeps when there ...
0
votes
2answers
572 views

Memory allocation of Classes that don't have any global data and locks

static void Main(string[] args) { var c2 = new Class2(); var c3 = new Class3(); var c1 = new Class1(c2, c3); c1.Method1(); } class Class1 { ...
-1
votes
2answers
200 views

When will be safe to choose Multi-thread design without dead lock? [closed]

Sometime we really need to choose a multi-threaded design, because single-threading will block the UI or block another thread. But sometimes using multiple threads is just one of the choices, for ...
1
vote
2answers
206 views

What are the different aspects to consider when porting code from a single threaded environment to a multi threaded environment or vice versa?

I want to provide some library functionality and a reference application, which will run on a fully-featured, POSIX-compliant platform. The app and library will need bi-directional serial port ...
3
votes
1answer
105 views

Are mutexes assigned to specific regions of memory?

I'm currently reading C++ Concurrency in Action by Anthony Williams and I'm facing an obstacle in thought. First he describes deadlocks as when two threads lock simultaneously (at least, that's how I ...
4
votes
1answer
632 views

Design patterns for multi-threaded messaging server

I'm designing an instant messaging server as a personal exercise to improve my understanding and application of multi-threading and design patterns in Java. I'm still designing, there's no code yet. ...
2
votes
1answer
367 views

Python multithreading and utilizing modern processors - what is the downside?

CPython implementation detail: In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome ...
1
vote
2answers
123 views

Listener, logger, plotter - what threading arcitecture to choose for this?

I am constructing a program that does several things. Listens to a port. Every second a string is received When new data is received, it has to be logged. No errors or skipped entries are allowed ...
3
votes
5answers
357 views

What are some good assignments for an introductory course on concurrent programming? [closed]

I am teaching a course which involves introducing the students to the concept of threads and concurrent programming. I am in search of programming assignments that can gently get them to accept the ...
2
votes
2answers
231 views

How do I get rid of cyclic references in this design?

I have 3 classes: Meeting, Project and Agenda. A Project contains all sort of information + a list of meetings. The Agenda contains a list of upcoming Meetings. A Meeting contains some data + a list ...
2
votes
1answer
216 views

Multi-Thread Return Single SQL Result

I am having some difficulty with MySQL and returning a unique row to a thread. I want it so the thread will search for a row from the table where the bit (see below) is false and only one row is ...
1
vote
1answer
187 views

How do I find a good middle way to make this library safe for concurrent operations

I've made a little library called SignalR.EventAggregatorProxy Before I push it into 1.0 state I need to fix so it works safely with concurrent operations. Easiest way is lock all operations but ...
1
vote
1answer
542 views

Which child process will inherit threads of parent process?

What happens when one process have child threads and child process , will child process inherit all child threads of parent process.? Assume OS is Linux . Let it be Java Threading model.
3
votes
4answers
883 views

Should multi-threading be used for tasks which does not involve IO operation?

I was reading a book on OS and got confused between different terminologies. I hope i will get my doubt cleared here. These questions might be very basic for some experts, but i find this platform ...
1
vote
1answer
1k views

How to make a method synchronized across all instances of an object

Today I was asked this interview question and could not answer. : If you have two instances of a Person Object and each of them have a setAddres method that is synchronized. Now if it was only one ...
6
votes
3answers
1k views

How many threads should access the file system at the same time?

We have a module in an application which stores data in multiple files and multilevel directories and access them from multiple threads (both reads and writes). The directory structure is based on a ...
9
votes
2answers
708 views

Uses of persistent data structures in non-functional languages

Languages that are purely functional or near-purely functional benefit from persistent data structures because they are immutable and fit well with the stateless style of functional programming. But ...
-1
votes
1answer
216 views

What operating systems use both a Render thread and a UI thread?

Microsoft employees commonly describe Windows 8 as having both a Render thread and UI thread. Typically they say the Render thread performs animations and the UI thread handles most other operations: ...
6
votes
2answers
4k views

How is multi-threading different in a Java based Web Application vs Stand-alone Java Application

I am fairly new to Java and my experience is limited to Web Based Applications running on a Web Container (Jboss in my case). Am I correct in saying that for Web Applications the web container takes ...
1
vote
1answer
2k views

High-Load Java Server for Multiplayer

I am making a multiplayer game. Now I am trying to choose the technology to connect the android devices to the server. The clients run on Android, and the game is MMORPG. I would like to write the ...
0
votes
2answers
135 views

Loading chunks around center

I am making a voxel game like Minecraft. I am able to load chunks using multithreading with the code... for (int x = 0; x < WorldSettings.WORLD_WIDTH_IN_CHUNKS; x++) { for (int y = 0; y < ...
1
vote
1answer
236 views

Is there a time bomb in sequential process id allocation when the `unsigned` wraps?

I'm designing and implementing a multiprocessing postscript interpreter ("lightweight" processes simulated by a single OS-thread), and I need to generate a unique identifier for each process in the ...
6
votes
4answers
674 views

Is it a performance hit to create threads that loop a lot to check for things?

This is a generic question that I've always wondered. In general, is it intensive for a CPU to create threads that perform "while not true ..." loops or similar? For example, suppose I do: // ...
8
votes
2answers
716 views

Would Task-based programming in C++ require new language standard features?

So I saw this video on Youtube with all these C++ masters on GoingNative 2012 : Interactive panel where everybody could ask the questions. This is the video I was talking about: GoingNative 2012 - ...
6
votes
4answers
2k views

Threads or ThreadPool? Fixed or Dynamic ThreadPool?

I have a java program which listens on a port for input. Based on Input, it calls a webservice and then returns a success/failure back to the client program. I fork a thread for each client ...
0
votes
2answers
458 views

Multi-Threaded JavaScript?

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 ...
27
votes
5answers
2k views

Testing multi-threaded race conditions

Reading the comments to this answer, specifically: Just because you can't write a test doesn't mean it's not broken. Undefined behaviour which usually happens to work as expected (C and C++ are ...
2
votes
2answers
313 views

Send stdout or stderr to a new thread

For performance issue I want the logging send to a new thread. While the main program can work, the new thread can write the error or other messages to a file without effect to the main program. How ...
0
votes
1answer
2k views

Android game loop in separate thread

I am about to port a game that was initially written for iOs and I am having some doubts how certain things should be done. I have been looking many of the examples of the game loops for android, and ...
13
votes
1answer
829 views

Best practise is not to poll…but isn't polling happening internally anyway when a thread calls wait()?

Say we have some thread that wants to check when another thread is finished its task. I have read that we should call a wait() type function that will make this thread wait until it receives a ...
0
votes
1answer
397 views

Multi-threaded server

I have written a server/client program in which I am using 2 threads : One to recieve data continously and Other to send data as the user writes it on screen Problem: I have created the threads ...
-2
votes
2answers
152 views

Calling blocking functions and execute code when result is ready, but without callbacks

I am designing an application that has some scripting capabilities: the host application may call the scripts to perform some operations when some events occur. To keep it easy and newbie-friendly, ...
7
votes
2answers
333 views

How to maintain synchronised state across threads - is this a good use for a Singleton?

I hear a lot about "Singletons are always bad" around the place. I don't hate on them to that degree but I try not to use them if I have a better alternative. In this case I have a system that ...
2
votes
3answers
190 views

Is there a way to calculate whether to spawn a new thread or use current thread

I am building an interpret DSL in which parallelism is part of the language - the user simply states that a calculation can be done in parallel and the interpreter may decide whether to make the ...
1
vote
0answers
99 views

Thread safety IDE warnings

I wonder, would it not be possible for an IDE to detect any shared mutable objects that are used in multiple threads? You could flag types as either [ThreadSafe] or [Immutable] using attributes in ...
5
votes
2answers
438 views

Allow threads (in c) to print messages without interfering with user input

I'm a writing a small webserver for personal use in c (not c++). I want to allow user input in the console like "shutdown server" or "restart server". In order to allow this kind of input the server ...
8
votes
3answers
5k views

BackgroundWorker vs. Async/Await

I am new to C# development and wish to create a more responsive UI. In my preliminary research, I have seen two methods for achieving this: Multi-threading in conjunction with the BackgroundWorker ...