multithreading

How to implement ConcurrentHashMap with features similar in LinkedHashMap?

I have used LinkedHashMap with accessOrder true along with allowing a maximum of 500 entries at any time as the LRU cache for data. But due to scalability issues I want to move on to some thread-safe alternative. ConcurrentHashMap seems good in that regard, but lacks the features of accessOrder and removeEldestEntry(Map.Entry e) found in...

I am new to threads, What does this compile error mean?

Using C++. pthread_t threads[STORAGE]; // 0-99 ... void run() Error>>> int status = pthread_create(&threads[0], NULL, updateMessages, (void *) NULL); if (status != 0) { printf("pthread_create returned error code %d\n", status); exit(-1); } ... void ClientHandler::updateMessages(void *) { string reqUpdate = "91"; // Reques...

Details of AsyncWaitHandle.WaitOne

1)The call AsyncWaitHandle.WaitOne may block client or will definitely block the client?. 2)What is the difference between WaitAll,WaitOne,WaitAny? ...

java.util.ConcurrentModificationException in Non Multithreaded Program,

Hey SO Guru's im having one heck of a job with this code public void kill(double GrowthRate, int Death) { int before = population.size(); for (PopulationMember p : population) { int[] probs = ProbablityArrayDeath(GrowthRate,Death,(int)p.fitness()); if (probs[RandomNumberGen.nextRandomInt(0, 99)]==0) ...

Can't pickle <type 'instancemethod'> when using python's multiprocessing Pool.map()

Hi, I'm trying to use multiprocessing's Pool.map() function to divide out work simultaneously. When I use the following code, it works fine: import multiprocessing def f(x): return x*x def go(): pool = multiprocessing.Pool(processes=4) #result = pool.apply_async(self.f, [10]) #print result.get(timeou...

C# - Queue and multithreading

I am very new to multi-threaded programming. Following is what I am trying to achieve: Create a windows service that continuously reads the database (or somekind of message queue, please suggest what would be best) for a entry in a table. Look for a new entry in the table If there is a new entry, check if there is enough thread in...

C# threading issue

To play a bit with threading, delegates and backgroundworkers, I'm putting together a few small applications, I'm having a bit of trouble with one of them. I've a Windows form, with a textbox, a button and a richttext. When I press the button, the text in the textbox is used as a paramter to instantiate a class, like this: public partia...

How much thread-safety is too much?

I've been reading Java Concurrency in Practice lately – great book. If you think you know how concurrency works, but then most of the time you face the real issues, it feels like SWAG is the most you can do, then this book will certainly shed some light on the topic. It's sort of scary how many things can actually go wrong when you try t...

Multithreading won't work as expected

Hello, I have a problem with my program. I wanted it to have two threads, one of them listening for connections, and the other one receiving data from them... Unfortunately, it acts strangely. It will ignore my cout and cin usage everywhere in the code, so I can't even debug it. May I ask that someone sheds some light on it? Thank you in...

C# Thread Programming

Possible Duplicate: Thread vs ThreadPool What are the benefits of using ThreadPool instead of creating our own? ...

C#: Do I have to make ArrayList synchronized if multiple threads only read it

I'm using static ArrayList in a class to store information about non-updatable database fields. I'm planing to initialize it in constructor once (init method call guarded by lock in constructor). After that multiple threads check if arraylist Contains a field. Do I have to control this read access in any way? For example by calling Array...

Interrupting a thread that waits on a blocking action?

I am running a thread whose main action is to call on a proxy using a blocking function , and wait for it to give it something. I've used the known pattern of a volatile boolean and the Interruption , but I'm not sure it will work: When I tried to add a catch block for "InterruptedException" , I get the error "Unreachable catch block ...

what is the right way to spawn thread for database IO in asmx web service?

Hello. I have a short lock guarded section in a method (that serves the request entirely) that makes all initializations (etc. log-related). So only 1 thread can be there at time. In this section I also load system data from database if not loaded. This is naturally executed only on 1st request and it does not matter it takes time and n...

How can I know when a thread ends on .Net Compact Framework?

Hello. I'm developing a Windows Mobile 5.0 and above application using .Net Compact Framework 2.0 SP2 and C#. How can I know when a thread ends? This is my code: System.Threading.Thread thread1 = new System.Threading.Thread(() => RetreiveSoMuchData(ID)); thread1.Start(); Thank you. ...

BackgroundWorker From ASP.Net Application

We have an ASP.Net application that provides administrators to work with and perform operations on large sets of records. For example, we have a "Polish Data" task that an administrator can perform to clean up data for a record (e.g. reformat phone numbers, social security numbers, etc.) When performed on a small number of records, the t...

Is RLock a sensible default over Lock?

Dear all, the threading module in Python provides two kinds of locks: A common lock and a reentrant lock. It seems to me, that if I need a lock, I should always prefer the RLock over the Lock; mainly to prevent deadlock situations. Besides that, I see two points, when to prefer a Lock over a RLock: RLock has a more complicated intern...

incorrect function being called on multiple fast calls to python's threading.Thread()

I'm having some problems with launching threads from a list of functions. They are in a list because they are configuration-specific functions. I'm wrappering the functions so that I can store the results of the functions in 'self', but something is going wrong in a non-threadsafe way that I get the right number of threads started, but s...

File read by interrupt in java

Hi, I am using a text file to store the serial port output. And now I want to put the contents of the file to an textArea in java. I have created a dedicated thread for file read operation. I need the thread to sleep when there is no data to read and thread should wake up automatically once data available for read in the file. In the th...

Thread synchronization in C#?

I have lots of few small functions, each executes a query. I want only one function to be running at a time, what is the best possible way of thread sync to avoid database locked issue in SQLite (C#). The functions are in multiple classes, how will you lock all the functions in all the DB classes, so that only one function from any of t...

First thread signal is not caught all others caught

Hey all, Quite a specific question, but I was wondering if anyone has had any problems getting the first signal to be caught in a consumer-producer relationship with multiple consumers (HTTP web server) for(i = 0; i < num_threads; i++) { pthread_cond_init(&condVars[i], NULL); if(strcmp(policy,"FIFO") == 0) pthread_create(&threadArr...