multithreading

GlobalInterfacePointer passing using AfxBeginthread

Hi, I am using a worker thread inside a CDialog class. theApp.m_pWorkerThread = AfxBeginThread(Threadproc,this); Now I need to pass a global Inerface poiner to the worker thread so as to access a COM object from outside Can someone tell me the syntax to pass the GIT cookie and access it inside the thread. Thanks ...

Get calling context in a service

So I'm working on a service that will handle requests to send data to a socket. I've done socket programming in a service before, but only within the same application. I'd like this to just sit and do nothing until any application wants to give it data to send. That's all well and good. I have register an intent filter and the usual st...

How to pause and show video capture using JMF?

Hi. I need to make an applet using JMF that will capture video from the webcam, show it to the user while it's recording and have a pause option to pause ( not stop ) the video capture. I already know how to capture the video and audio and save it to a local file, but, as I said, I need to give the user the option to pause this captur...

In Java, how to log a message every time a given object's monitor is entered or exited?

I am trying to debug some C/Java bindings that use some custom refcounting/locking. I would like to have the JVM print a message every time a given object has its monitor entered or exited. Is there any way to do this? Basically, I want this: synchronized(lock) { ... System.out.println("hi"); ... } to print this: *** "lock" ...

java: New to threads. Is this possible?

Hi, I'll try to be short. Need a number of threads to open sockets (each thread opens one socket) and make HTTP Requests. I am new to multi-threaded and I don't know if this is possible, since each thread must be running until the request is finished (i think). [edit after comments] I don't know if this is possible since currently run...

File access synchronized on Java object

I have an object responsible for persisting JTable state to disk. It saves/loads visible columns, their size, position etc. A few interesting bits from its class definition are below. class TableSaver { Timer timer = new Timer(true); TableSaver() { timer.schedule(new TableSaverTimerTask(), 15000, SAVE_STATE_PERIOD); ...

Resources for learning memory model and Thread safety in java

I have been searching for resources to understand thread safety in java and came across this. Is there any popular/comprehensive resource or books that explains thread safety in a more simpler way, perhaps with more sample programs. I found the above resource hard to understand. Thanks! ...

Perl Threads and Unsafe Signals

So I recently wanted to thread one of my Perl programs to increase its speed. Taking in a list of websites, I wanted to start a thread for each url and get the content of each website and then look for a company description on the page. Once one thread found a result, or all thread's didn't, I wanted to exit, write my result, and read ...

c# A problem with WebRequest.AddRange() method - seems not to be working ?

Hi, I want to create my own multi-threading file downloader, and - as I am reading and alpha-testing some code examples, I've found a weird scenario - when I test the code below, I paste a download link that the server does not supports SeekOperations, so I must dowload the file in 1 thread. When I paste the same download link to e.g Fl...

Instantaneous interruption of a Boost::thread

I'm trying to implement a program which runs a function limited by a fixed amount of time. I've managed to do it with pthreads but I would like to use Boost::thread. So far I've coded the following: #include <boost/thread.hpp> #include <unistd.h> #include <signal.h> #include <iostream> using namespace std; boost::thread mythread; vo...

Question regarding multiple threads and segfaults

What happens when two threads of the same process running on different logical cpu hit a seg fault? ...

Why is performSelector:onThread:withObject:waitUntilDone: not recommended for frequent inter-thread communication.

Apple's Threading Programming Guide states that: Although good for occasional communication between threads, you should not use the performSelector:onThread:withObject:waitUntilDone: method for time critical or frequent communication between threads. Which begs the questions: Which is, then, the acceptable method for freq...

Communicating end of Queue

I'm learning to use the Queue module, and am a bit confused about how a queue consumer thread can be made to know that the queue is complete. Ideally I'd like to use get() from within the consumer thread and have it throw an exception if the queue has been marked "done". Is there a better way to communicate this than by appending a sen...

Memory management responsibility during inter-thread communication.

If thread A sends a reference to an object to thread B, for example using performSelector:onThread:withObject:waitUntilDone, how should memory management occur? Should the calling thread alloc the object and the called thread release it? EDIT: It turns out that performSelector:onThread:withObject:waitUntilDone retains the object unti...

backgroudWorker and forms : weird hang

Hello everyone, I am stuck since few days on a bug in my app, and I require help. Main thread contains time consuming operation. To be more friendly with user, I created a static class Info, which contains to methods ShowInfo and StopInfo. ShowInfo basically start a backgroundWorker. backgroundWorker operation is : Create a form sh...

HttpModule threading

Trawling through the 'net I'm getting lots of conflicting posts as to whether the HTTPModule route is single threaded or multithreaded by default. I'm trying to debug rapidly differing performance within local, UAT and deployment environments and am wondering whether there is a pinch point with HTTPModule that I've been previously unawa...

C# thread lock failed

I have two working threads.I have locked both with a same lock, but threadB is getting executed before threadA, so exception came.I locked both using the same lock object.Thread B is using delegate function.How can I solve the issue. Detailed Information: I have a class called StateSimulation. Inside that there are two functions call...

What are the thread limitations when working on Linux compared to processes for network/IO-bound apps?

I've heard that under linux on multicore server it would be impossible to reach top performance when you have just 1 process but multiple threads because Linux have some limitations on the IO, so that 1 process with 8 threads on 8-core server might be slower than 8 processes. Any comments? Are there other limitation which might slow the...

Thread-safe asynchronous code in C#

Hi all, I asked the question below couple of weeks ago. Now, when reviewing my question and all the answers, a very important detail jumped into my eyes: In my second code example, isn't DoTheCodeThatNeedsToRunAsynchronously() executed in the main (UI) thread? Doesn't the timer just wait a second and then post an event to the main threa...

Linux Log4CXX Log4J

What is better in my application (called MyApp) that has the following 2 classes. MyApp is a multithreaded application requiring ClassA and ClassB. Also ClassA and ClassB spawn P-threads. The underlying system is Linux and the logging library used is Apache's Log4CXX. //ClassA: LoggerPtr ClassA::logger(Logger::getLogger("ClassA")); //C...