multithreading

How to create a thread that runs all the time my application is running

EDIT: I'm now sure that the problem is related to the while (true) loop holding all other commands as I've commented it out and the application deploys without the attached exception. I'm not sure how much it is important but my ServletContextListener implementation looks like this: public class BidPushService implements ...

Suggestions for a thread safe non-blocking buffer manager

I've created a simple buffer manager class to be used with asyncroneous sockets. This will protect against memory fragmentation and improve performance. Any suggestions for further improvements or other approaches? public class BufferManager { private int[] free; private byte[] buffer; private readonly int blocksize; pu...

How can I continuously QueueUserWorkItems but without queuing them all at once?

I'm working on a multi-threaded scraper for a website and as per a different question I've decided to use the ThreadPool with QueueUserWorkItem(). How can I continually Queue work items without queuing them all at once? I need to queue > 300k items (one for each userID) and if I loop to queue them all I'll run out of memory. So, what ...

synchronization in java

Here is simplified version of my requirement I have a java class say Processor that contains a method say bigProcess() all it does is connect to a file server, download a specified file once that is done save the file in DB and after that update some of the DB fields in different tables. For each of the subtasks like download file, sav...

WebSphere Portal portlet crazy threading

Hello, We are dealing with an issue in our WebSphere Portal solution. It's a stand-alone application server, running WebSphere Portal on top of WebSphere 6.0 and all the stack is installed by another IBM product: WCL - Workplace Collaborative Learning (an e-learning plataform). It's a Windows Server 2003 install, btw. The issue is that...

Thread safe C++ std::set that supports add, remove and iterators from multple threads

I'm looking for something similar to the CopyOnWriteSet in Java, a set that supports add, remove and some type of iterators from multiple threads. ...

C++/CLI ref class using a win32 thread

I'm trying to encapsulate some older win32 code in a C++/CLI ref class to make it better accessible from .NET code. This class needs to start a Win32 thread and pass a pointer to the class as a thread parameter. The code looks something like this: ref class MmePlayer { int StartPlayback() { hPlayThread = CreateThread(NUL...

Wanted: Elegant solution to race condition

I have the following code: class TimeOutException {}; template <typename T> class MultiThreadedBuffer { public: MultiThreadedBuffer() { InitializeCriticalSection(&m_csBuffer); m_evtDataAvail = CreateEvent(NULL, TRUE, FALSE, NULL); } ~MultiThreadedBuffer() { CloseHandle(m_evtDataAvail); DeleteCriticalSection(&m_csBuffer); ...

Synchronization in threads for Java

I have a home grown web server in my app. This web server spawns a new thread for every request that comes into the socket to be accepted. I want the web server to wait until a specific point is hit in the thread it just created. I have been through many posts on this site and examples on the web, but cant get the web server to proceed...

Optimizing an ASMX web service with Multiple Long-Running Operations

I'm writing an ASP.NET web service using C# that has a DoLookup() function. For each call to the DoLookup() function I need my code to execute two separate queries: one to another web service at a remote site and one to a local database. Both queries have to complete before I can compile the results and return them as the response to t...

how to set CPU affinity of a particular pthread?

Hi, I'd like to specify the cpu-affinity of a particular pthread. All the references I've found so far deal with setting the cpu-affinity of a process (pid_t) not a thread (pthread_t). I tried some experiments passing pthread_t's around and as expected they fail. Am I trying to do something impossible? If not, can you send a pointer ple...

Thread local storage in Python

How do I use thread local storage in Python? Related What is “thread local storage” in Python, and why do I need it? - This thread appears to be focused more on when variables are shared. Efficient way to determine whether a particular function is on the stack in Python - Alex Martelli gives a nice solution ...

StackTrace from Exception on different thread?

There is a constructor on StackTrace that takes an exeption as an argument. All fine and well, but I noticed that all the other constructors say that it will get the StackTrace from the current thread, but the constructor taking the exception does not say anything about that other than The resulting stack trace describes the stack...

SQL last insert in Drupal. Is it really threadsafe?

I have a query that might be executed by several users consecutively. I'm scared that if I run the db_last_insert_id command, some users might not get the last insert id, due to concurrency. But according to: http://api.drupal.org/api/function/db%5Flast%5Finsert%5Fid/6, it sates: Returns the last insert id. This function is thread sa...

Threads in Session Beans

Hi, I have a session bean that uses Bean managed txns. This bean has one business method that simply delegates the control to a POJO which takes care of all the processing. Here this POJO starts and closes transactions (UserTransaction). Now the question is can I span new threads in the POJO so that I can create a new thread when I nee...

Tibco Rendezvous in-process drops messages - does it happen?

We use Rendezvous to send information from one thread to another in the same process. It seems that we drop a few messages per session (hundreds of thousands or millions of messages). I could not find any obvious fault in our own code, so I am asking the community: Rendezvous is not a guaranteed delivery service (unless you specify that ...

waiting for multiple condition variables in boost?

I'm looking for a way to wait for multiple condition variables. ie. something like: boost::condition_variable cond1; boost::condition_variable cond2; void wait_for_data_to_process() { boost::unique_lock<boost::mutex> lock(mut); wait_any(lock, cond1, cond2); //boost only provides cond1.wait(lock); process_data(); } ...

Too Many Threads Exception

I am facing problem in blackberry development. In my application I have to get images from the server, so i have to create a separate connection thread for each image i load from the server..but in doing so i am getting TooManyThreadsException..Any ideas regarding controlling the threads... In blackberry an application can have maximum...

thread-safe function pointers in C++

I'm writing a network library that a user can pass a function pointer to for execution on certain network events. In order to keep the listening loop from holding up the developer's application, I pass the event handler to a thread. Unfortunately, this creates a bit of a headache for handling things in a thread-safe manner. For instance,...

speeding up sending large batch of emails in c# .net

hello, We send out emails to around 10k client and right now the process takes around 45 min or so. The application runs on the server and just sends out the whole batch. I'm wondering if introducing threads and splitting up the list would speed up the process. If so, how many threads are optimal? EDIT: actually it is one message t...