multithreading

static selector between threads on nio server

I need to implement a server in which has only one selector(static); multiple threads try to register channel to the same static selector. I tried to implement the server, but the problem is that the static selector works for first time i.e. registers the channel; but on next call to register different channel the thread gets hanged. I...

Any bugs or incompatibilities in 64 bit JVM?

Hi guys, I've got a little game that a friend and I are writing in Java. It's kind of badly coded and we're working on refactoring it, but that's not really the issue right now. We both have 64 bit machines and I guess before we were both using 32 bit JDKs, but recently I had some problems and so I removed all JDKs and installed the lat...

Is modifying a class variable in python threadsafe?

I was reading this question (which you do not have to read because I will copy what is there... I just wanted to give show you my inspiration)... So, if I have a class that counts how many instances were created: class Foo(object): instance_count = 0 def __init__(self): Foo.instance_count += 1 My question is, if I create Foo ...

Synchronizing COM Threads with .NET

In our C# application we are making use of a thirdparty (Thesycon) COM object which runs threads to write data to a scanning device from 7 files. I start the writing method by calling COM.StartWriting() and I can stop it by calling COM.StopWriting() Now the problem is I'm unable to synchronize the threads. This means out of 7 I a...

Parallel coding Vs Multithreading (on single cpu)

can we use interchangeably "Parallel coding" and "Multithreading coding " on single cpu? i am not much experience in both, but i want to shift my coding style to any one of the above. As i found now a days many single thred application are obsolete, which would be better for future software industy as a career prospect? ...

fork and existing threads ?

On a linux system, does the child process view the existing threads the same way as the parent process ? int main() { //create thread 1 . . . int child_pid = fork(); if ( 0 == child_pid) { .. } else { .. } Since the whole address space is copied for the child process, what happens to the state of the threads. What if the thread 1 in...

Are nonblocking I/O operations in Perl limited to one thread? Good design?

I am attempting to develop a service that contains numerous client and server sockets (a server service as well as clients that connect out to managed components and persist) that are synchronously polled through IO::Select. The idea was to handle the I/O and/or request processing needs that arise through pools of worker threads. The sh...

SQL problem - high volume trans and PK violation

I'm writing a high volume trading system. We receive messages at around 300-500 per second and these messages then need to be saved to the database as quickly as possible. These messages get deposited on a Message Queue and are then read from there. I've implemented a Competing Consumer pattern, which reads from the queue and allows for...

how do I implement in C# a method that returns only when some user event happens?

what I am getting at is something like OpenFileDialog.Show() method that returns after indefinite amount of time, only after user does something (presses Ok in this case). Well, I know that I can achieve similar things for dialog controls by subclassing from dialog, or form, or something like that. But what if I want to do it for somethi...

help needed in selector issue nio, threading

I need to implement a server in which has only one selector(static); multiple threads try to register channel to the same static selector. I tried to implement the server, but the problem is that the static selector works for first time i.e. registers the channel; but on next call to register different channel the thread gets hanged. I...

Threadsafe Generic Extension method usage syntax problem

Here's my extension method for invoke on a control: public static void Invoke<T>(this T c, Action<System.Windows.Forms.Control> DoWhat) where T:System.Windows.Forms.Control { if (c.InvokeRequired) c.Invoke(o=> DoWhat(c) ); else DoWhat(c); } ds is a strongly typed dataset. This works: Action<DataGridView> a = row => row...

Please help me make this code thread safe

I've got a bit of a problem with making my data loading and filtering thread safe. The following code on my control's base class which handles all the data population through a BackgroundWorker. This tends to throw the error on "this.DataWorker.RunWorkerAsync()" saying that the BackgroundWorker is busy. /// <summary> /// Handles the po...

C++ - how does Sleep() and cin work?

Just curious. How does actually the function Sleep() work (declared in windows.h)? Maybe not just that implementation, but anyone. With that I mean - how is it implemented? How can it make the code "stop" for a specific time? Also curious about how cin >> and those actually work. What do they do exactly? The only way I know how to "bloc...

I need some help using Threads in C#

Hello. I´m developing a software in C# that uses static functions from a C++ .dll file through a Wrapper. The problem is that some of these functions are slow and unstable, so in order to solve this I created a Thread that executes them. However, when I abort that thread from the main thread, the program isn´t letting me use those fun...

Processing Messages with Threads, efficiently?

I need help designing a message distribution system. So far I have 2 processes, one listening for remote client's to deliver messages, which are then written to a database table. I then have a second process that reads from this same table every [n] seconds,getting up to 100 messages in a single read, and if any new records, queues each...

Which is more Efficient? More Cores or More CPUs

I realize this is more of a hardware question, but this is also very relevant to software, especially when programming for mult-threaded multi-core/cpu environments. Which is better, and why? Whether it be regarding efficiency, speed, productivity, usability, etc. 1.) A computer/server with 4 quad-core CPUs? or 2.) A computer/server...

How to mmap the stack for the clone() system call on linux?

The clone() system call on Linux takes a parameter pointing to the stack for the new created thread to use. The obvious way to do this is to simply malloc some space and pass that, but then you have to be sure you've malloc'd as much stack space as that thread will ever use (hard to predict). I remembered that when using pthreads I didn...

Read/write synchronization

I have a data structure whose operations can be categorized as read operations (e.g. lookup) and write operations (e.g. insertion, removal). These operations should be synchronized so that: Read operations can't execute while a write operation is executing (unless on the same thread), however read operations can be executed concurrentl...

How use sqlite + fdbm library with threading on the iPhone

Related to this SO question, I want to put the data loading in the background. However, I get 'library routine called out of sequence' errors. In this SO thread say that the way is using NSOperation, but looking on the samples on the web I not know how that could solve the issue. I share a single sqlite connection with the singleton p...

Where is InterlockedRead?

Win32 api has a set of InterlockedXXX functions to atomically and synchronously manipulate simple variables, however there doesn't seem to be any InterlockedRead function, to simply retrive the value of the variable. How come? MSDN says that "Simple reads and writes to properly-aligned 32-bit variables are atomic operations", but adds t...