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

learn more… | top users | synonyms (5)

2
votes
1answer
390 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
143 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
415 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
242 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
226 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 ...
0
votes
2answers
187 views

Queues and threading

I am developing a new project where I will be constantly checking a webpage for data and adding this data to a queue for processing. This data will then be removed from the queue and added to a list ...
1
vote
1answer
191 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
747 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.
4
votes
4answers
1k 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
2k 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 ...
5
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
803 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
229 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: ...
2
votes
4answers
496 views

How to convince my teammates that spawning numerous threads is a bad design? [closed]

I've stumbled upon this problem when tried to run our application in bad network conditions; it spawns hundreds of threads (which exist long time before termination), and with time the application ...
6
votes
2answers
5k 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 ...
2
votes
1answer
3k 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
144 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
252 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
841 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
820 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 - ...
7
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
524 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 ...
29
votes
5answers
3k 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 ...
31
votes
3answers
7k views

Is GCC dying without threads support on Windows?

I need some opinion. GCC was always a very good compiler, but recently it is losing "appeal". I have just found that on Windows GCC does not have std::thread support, forcing Windows users to use ...
2
votes
2answers
350 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
925 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
472 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
154 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
345 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
191 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
100 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
533 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 ...
1
vote
1answer
197 views

What makes a series of machine instructions an actual process/thread in memory?

Every instruction comes from main memory/RAM. In a bootloader, at least on Intel and IBM PC firmware and designations, you have BIOS jump to a memory address to begin fetching instructions for ...
9
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 ...
0
votes
2answers
184 views

How bad would it be to obtain a lock on every object?

Imagine a hypothetical programming environment that is largely like Java or .NET, i.e. object-oriented, garbage-collected, etc., but with one small change: Every time you call a method on an object, ...
2
votes
2answers
191 views

Should I split out synchronization from my class and what's it called?

When thinking about testability and modular code, I recently thought about whether I should split out the synchronization part of a class from the actual behavior part. By example: The app "needs" ...
20
votes
3answers
7k views

Why Was Python Written with the GIL?

The global interpreter lock (GIL) seems to be often cited as a major reason why threading and the like is a touch tricky in Python - which raises the question "Why was that done in the first place?" ...
4
votes
1answer
816 views

Spurious wakeups explanation sounds like a bug that just isn't worth fixing, is that right?

According to the Wikipedia article on Spurious Wakeups "a thread might be awoken from its waiting state even though no thread signaled the condition variable". While I've know about this ...
26
votes
8answers
3k views

When would you need “hundreds of thousands” of threads?

Erlang, Go, and Rust all claim in one way or another that they support concurrent programming with cheap "threads"/coroutines. The Go FAQ states: It is practical to create hundreds of thousands ...
3
votes
2answers
5k views

JUnit Testing in Multithread Application

This is a problem me and my team faces in almost all of the projects. Testing certain parts of the application with JUnit is not easy and you need to start early and to stick to it, but that's not the ...
-1
votes
2answers
955 views

Should I use simple socket programming to communicate between 2 threads? [closed]

Is it a good idea to communicate between 2 threads using sockets in Java? What I am trying to achieve is Inter-process communication using socket programming/RPC mechanism.
4
votes
2answers
410 views

What is a good script language for writing server administration tasks? [closed]

I am administering hundreds of RHEL servers. There are many daily tasks to perform. Right now I am working with bash scripting and python. I was wondering if other languages such as Erlang, Lua, Ruby, ...
1
vote
2answers
820 views

How to preserve order of incoming requests on a multithreaded server

I want to write a multithreaded server application which is able to process requests in a multithreaded fashion while keeping up execution order of incoming requests of the same client. For example ...
2
votes
2answers
2k views

Can multiple CPU's / cores access the same RAM simutaneously?

This is what I guess would happen: If two cores tried to access the same address in RAM, one would have to wait for the other to access the RAM. The second time that each core would try to access ...
1
vote
2answers
1k 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 ...
-1
votes
2answers
1k views

Difference between daemon and child thread?

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 ...
-2
votes
1answer
398 views

Why notify and wait are not declared in threads?

wait and notify are said to be communication mechanism in threads but then why are they not declared in Thread class and are declared in Object class instead?
5
votes
1answer
1k views

Many Blocking VS Single Non-Blocking Workers

Assume there is an HTTP server which accepts connections and then it has somehow wait for headers to be fully sent in. I wonder what is the most common way of implementing it and what are the rest ...
5
votes
1answer
7k views

How to program thread allocation on multicore processors?

I would like to experiment with threads on a multi-core processor, e.g. to create a program that uses two different threads that are executed by two different processor cores. However, it is not ...