Multi-threading related questions including technique, structure, and safety issues.
2
votes
1answer
54 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
1answer
67 views
Whats the 'avarage best' 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 safly with concurrent operations. Easiest way is lock all operations but thats ...
1
vote
1answer
60 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
3answers
178 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
121 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
275 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 ...
6
votes
2answers
169 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 ...
0
votes
1answer
127 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: ...
4
votes
1answer
393 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
214 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
78 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
165 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
249 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:
// ...
6
votes
2answers
258 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 - ...
3
votes
4answers
375 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
234 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 ...
23
votes
5answers
1k 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 ...
0
votes
0answers
37 views
Object pooling in managed environments
My application tries to process chunks of data, each sized at tens of megabytes, but not fixed size.
I use a producer for data fetching, and consumer for data processing,
Since I do not control the ...
2
votes
2answers
198 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
431 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
553 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
311 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
125 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
238 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
181 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
92 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 ...
4
votes
2answers
210 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 ...
7
votes
3answers
1k 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 ...
2
votes
2answers
139 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" ...
2
votes
1answer
267 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 ...
21
votes
6answers
1k 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 ...
2
votes
2answers
382 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 ...
4
votes
2answers
212 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, ...
0
votes
2answers
301 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
753 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
489 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
331 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
170 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
203 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 ...
2
votes
1answer
2k 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 ...
15
votes
3answers
2k 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, ...
6
votes
4answers
364 views
What is thread safety?
What is it? I was reading Effective STL and came across it. I have also Googled it, but couldn't get any helpful info.
0
votes
1answer
160 views
How to create a Request Specific Thread Safe Static int Counter?
In one of my server application I have a class that look like,
class A
{
static int _value = 0;
void DoSomething()
{
// a request start here
_value = 0;
_value++;
...
3
votes
4answers
1k views
Difference between Atomic Operation and Thread Safety?
From the discussion I've seen it seems that atomic operation and thread safety are the same thing, but a lot of people say that they're different. Can anyone tell me the difference if there is one?
0
votes
1answer
249 views
Relationship between “Task Parallel Library” and “Task-based Asynchronous Pattern”?
In the context of C#, .NET 4/4.5 used for an application running on a web-server, what is the relationship between "Task Parallel Library" and "Task-based Asynchronous Pattern"?
I understand one is ...
4
votes
2answers
303 views
Help me understand a part of Java Language Specification
I'm reading part 17.2.1 of Java language specification: http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.2.1
I won't copy a text, it's too long, but I would like to know, why for ...
1
vote
2answers
133 views
Requiring multithreading/concurrency for implementation of scripting language
Here's the deal: I'm looking at designing my own scripting/interpreted language for fun. I'm only in the planning stages right now; I want to make sure I have a very strong hold on exactly how I will ...
9
votes
7answers
481 views
Can you explain me why multiple threading need lock?
Assume these threads run in single core cpu. As a cpu only run one instruction in one cycle. That is said, even thought they share the cpu resource. but the computer ensure that one time one ...
7
votes
3answers
651 views
What is a thread pool?
In an interview question a guy was asked to "implement a threadpool"... I've been reading on wikipedia for "threadpool" but I still can't figure out what should a guy do to solve this question ...
0
votes
1answer
168 views
Is there a limit on the number of threads that can be spawned simultaneously?
Yesterday I came across this question: How can i call robocopy within a python script to bulk copy multiple folders?, and I though it might be a good exercise for multithreading.
I though of spawning ...