multithreading

Threadsafe Lazy Class

I have class Lazy which lazily evaluates an expression: public sealed class Lazy<T> { Func<T> getValue; T value; public Lazy(Func<T> f) { getValue = () => { lock (getValue) { value = f(); getValue = () => value; }...

error: can't start new thread

Hello my friends. I have a site that runs with follow configuration: Django + mod-wsgi + apache In one of user's request, I send another HTTP request to another service, and solve this by httplib library of python. But sometimes this service don't get answer too long, and timeout for httplib doesn't work. So I creating thread, in th...

Small Project to Learn Java Threads

I have been programming in java for a while (5 years), and I think that I have a good understanding of most of the aspects of the language. However, I think I haven't worked with threads as much as I would like to. What would be a good small project to learn java threads deeply? Any recommendations? Thanks ...

Lockless Deque in Win32 C++

I'm pretty new to lockless data structures, so for an exercise I wrote (What I hope functions as) a bounded lockless deque (No resizing yet, just want to get the base cases working). I'd just like to have some confirmation from people who know what they're doing as to whether I've got the right idea and/or how I might improve this. clas...

What is the difference between C# Thread.Sleep() and threadreference.Join()?

What is the difference between C# Thread.Sleep() and threadreference.Join()? ...

as many threads as process

given a stringlist containing 4 names. I need to call qprocess for each name in loop. To avoid freezing I am using qthread as suggested in this forum. given that (say): QStringList queueList contains 4 elements all.q, a1.q, a2.q, a3.q for(int z= 0; z < queueList.length(); z++) { // for each z call a thread that in turn will star...

Powershell async launching

I have a powershell script which executes from a c# call (ex.. Process.Start(powershell.exe file.ps1);) notepad.exe filename this however seems to block script completion, as the event of completion is not fired until the notepad dialog is closed. Is there a way for me to start notepad.exe but let the script complete execution. Maybe...

restart multi-threaded perl script and close mysql connection

I have a Perl script that reads a command file and restarts itself if necessary by doing: myscript.pl: exec '/home/foo/bin/myscript.pl'; exit(0); Now, this works fine except for one issue. The thread that reads the command file does not have access to the DBI handle I use. And over a number of restarts I seem to build up the number o...

Best practice for passing values from a non-UI thread to a UI thread in an Eclipse plugin application

Is there a best practice/shining example out there of passing values from a non-UI thread to a UI thread in an Eclipse plugin application? ...

What would be a realworld example of use of a barrier in a multithreaded application?

JDK's concurrency package, Boost's thread library, Perl's Thread library (not in Python though) all implement barrier, I haven't come across a need for using a barrier, so wondering what would a typical use case be in multi-threaded applications. ...

initWithContentsOfURL leaks memory within NSOperation subclass. Anyone else seeing this?

I have been living on Instruments for last few hours staring at a puzzling memory leak. I have isolated it to this single line of code in an NSOperation subclass I wrote: NSData *myData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:myURLString]]; Periodically this will leak 3500 bytes. Is anyone else seeing this? If so,...

Is it possible to use separate threads for reading and writing with Boost.Asio?

According to the Boost Documentation, having multiple threads call io_service::run() sets up a pool of threads that the IO service can use for performing asynchronous tasks. It explicitly states that all threads that have joined the pool are considered equivalent. Does this imply that it is not possible to have a separate thread for rea...

How many threadsd i have to use

The scenario is that there is lets say 1 TB of objects each of ten mb in database. I have a function named MATCH() which has a query object, whose return type is double, and in this function I have mathematical calculations. I have a check that if the value of the result is in between 0 and 1 then i have: double[ ] Result=new double[eg...

Asynchronous Delegates Vs Thread/ThreadPool?

Hello, I need to execute 3 parallel tasks and after completion of each task they should call the same function which prints out the results. I don't understand in .net why we have Asychronous calling (delegate.BeginInvoke() & delegate.EndInvoke()) as well as Thread class? I'm little confused which one to use when? Now in this particul...

Making a cross-thread call to a ListView

Hi, I have a thread running in the background that periodically tries to update a ListView component, but every time it attempts to I get a "Cross-thread operation not valid: Control 'dlList' accessed from a thread other than the thread it was created on." error. I have used a delegate to try and solve this but it isn't fixing the probl...

java: adding values to a map by multiple threads (is it possible ?)

is it thread safe to add elements to a Map by multiple threads at the same time ? Like if 10 threads add an element to a Map at exactly the same time, is the Map going to have 10 elements or 1 ? UPDATE: I don't need to iterate through this map, all I need is to add, remove and get elements by key ...

java thread safe code + an atomic method question

I have a class Manager that is going to be accessed by multiple threads at the same time, I want to know if I did it the right way ? also I think I need RemoveFoo to be atomic, but I'm not sure public class Manager { private ConcurrentHashMap<String, Foo> foos; //init in constructor public RemoveFoo(String name) { ...

Concurrecy issues with multiple instances of an object

Hi, the documentations always deals very explicitly with the issues of using one instance of an object with more than one thread. However what do I need to know when there are some threads that have their own instance at the same time? Which interference could occur? How do I handle members like SimpleDateFormat that are quiet expensive...

When a thread is blocked on Monitor.Enter(obj), is it put in obj's ready queue?

If so, that would imply that the blocked thread can enter when another thread calls Monitor.Wait(obj). This seems a little odd to me in that it must contend with other threads in the ready queue. If not, can it only un-block when Monitor.Exit(obj) is called? Or is it in obj's waiting queue? This isn't clearly documented in the MSDN Lib...

Why is UncaughtExceptionHandler not called by ExecutorService?

Hi, I've stumbled upon a problem, that can be summarized as follows: When I create the thread manually (i.e. by instantiating java.lang.Thread) the UncaughtExceptionHandler is called appropriately. However, when I use an ExecutorService with a ThreadFactory the handler is ommited. What did I miss? public class ThreadStudy { private st...