multithreading

Cherrypy multithreading example

I do know that cherrypy is a multithreaded and also has a threadpool implementation. So I wanted to try an example showing multithreaded behaviour. Now lets say I've my some function in the root class and rest all things are configured def testPage(self, *args, **kwargs): current = threading.currentThread() print 'Starting ' , c...

Get unique filename in a multithreaded application

I need to build a unique filename in a multithreaded application which is serializing some data on the disk. What approach could I use to ensure a unique name. The app was not multithreaded before and was using Ticks. When using multiple threads, it failed much faster than I expected. I now added the CurrentThreadId to the filename, and ...

boost::thread & member function

Hi all, I've facing this problem when trying to use boost::thread: unresolved external symbols: public: __thiscall boost::thread::~thread(void) public: __thiscall boost::thread::thread(void) Does anyone have any idea? ...

Daemon thread to wake up at different intervals

I have a daemon thread which wakes up at a specified interval to do some task. Now I need to add two more tasks to the thread & these tasks have their own intervals. Something like After every x seconds do Task1 After every y seconds do Task2 After every z seconds do Task3 So I basically need to come up with a sleep logic to ensure t...

Java printing & multithread

Hello, I wrote a little snippet called by php to print .postscripts files on a pre-defined network printer. While i print one file only, everything goes well, but when i try to set up a multi-thread printing management to send more then 1 file at once to the printer, only the first one comes out. The problem is that the PrintJobEvent P...

Java while loop in threads

I have written a program in Java which has 5 threads. In the run() I have a while loop which will loop over and over and this loop will loop a lot of times. While the program is running, it is gradually eating ram bringing the program to a crawl. Is there anyway I can stop it eating all my ram? Edit: Actually just thinking about it, i...

WPF Thread: "COM object that has been separated from its underlying RCW cannot be used."

I am getting following error: "COM object that has been separated from its underlying RCW cannot be used." I am sure the problem is because COM object is being called not on the thread it has been created - STA. I tried to implement IDisposable but it has not worked for me. There is a couple of posts dealing with similar problem but ...

Timed windows service crashing due to multiple threads running

Hi, I'm working on a simple web service which exports data from some data store into the database. The service runs every 20 seconds (testing interval). Intervals are implemented through System.Timers.Timer class. What is happening at the moment is: Service starts Timer starts 20 seconds pass and service starts the export Export do...

java thread synchronization problem, how to implements observable thread

The problem is: class C controls class B in terms of whether or not to let B add the A to the queueOfA back again, but how can I make sure that when A notifies C and update immediately before B's queueOfA becomes empty, because class B is running so fast that may remove all the A's so becomes an empty queueOfA before C doing the update, ...

CountDownLatch InterruptedException

I am using the CountDownLatch to synchronize an initialization process between two threads and i was wondering about the proper handling of the InterruptedException that it might throw. the code i initially wrote was this: private CountDownLatch initWaitHandle = new CountDownLatch(1); /** * This method will block until the...

Strange CUDA behavior in vector multiplication program

Hi, I'm having some trouble with a very basic CUDA program. I have a program that multiplies two vectors on the Host and on the Device and then compares them. This works without a problem. What's wrong is that I'm trying to test different number of threads and blocks for learning purposes. I have the following kernel: __global__ void m...

passing arguments to _beginthread() -- whats wrong?

I have this code and I am not getting the expected results... whats wrong? typedef struct { int data1; int data2; }t; void foo(int a, int b) { Handle handle; t arg; arg.data1 = a; arg.data2 = b; handle = (HANDLE) _beginthread( myFunc, 0, (void*) &arg); } void myFunc(void *param) { t *args = (t*) param; int ...

Executing a program as a thread and not as a process

Is there a way to execute another program, such as notepad, as a thread so it shares the same memory space as my program? So if my program ends, so will notepad and so that notepad won't show up in task manager, just my program? ...

Why doesn't this simple Lua coroutine work?

I have a very simple little piece of Lua code, which I wrote while teaching myself how coroutines work. I was fine until I got to coroutine.wrap, the spec states: coroutine.wrap (f) Creates a new coroutine, with body f. f must be a Lua function. Returns a function that resumes the coroutine each time it is called. Any arg...

StructureMap returns a disposed nHibenrate session object from thread local scope

I have this web application which uses SM for IoC. I am using HybridHttpOrThreadLocalScoped scope to store my nHibernate ISession objects. This works ok in a session per request fashion for my web requests. But I also have quartz.net that schedules couple of jobs. The job uses the same unit of work to get the ISession object. In this s...

Are View numbers affected by Bots on Forums?

I'm a second Admin on a forum and have noticed that the number of View of threads varies from thread to thread quite a bit. I was told that a lot of those Views are from the many Bots that come in and go thru the forums. My question is, do they up the View number every time they come in a check a new post in a thread, or are all of tho...

why quartz.net creates threads with same thread id?

I have setup quartz.net to run a scheduled job. It is amazing when I look at the thread ids. They just get repeated in 10-thread interval. I mean for instance if the first thread that gets to execute my job has id 101 then the eleventh thread (that runs the same job at the eleventh interval) has the same id 101! It seems that quartz.n...

write game via php

Hello I new in php and i interested at games like a poker. I think when started new game,there must be created new thread. But I read that php does not support multithreading. Can you advise what i must to do for support multithreading . Thank`s ...

some conceptual doubt on threading

i need to calculte the time taken to execute each thread.. so i used this code to do it. Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds,ts.Milliseconds); Console.WriteLine(ela...

How to use asyncsocket setRunLoopModes with separate thread?

I am new to cocoa and in my cocoa application, I'm trying to create the websocket in a new thread but it is not working. I'm doing the following when initializing mySocket class, NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(runEventLoop) object:nil]; [thread start]; .... - (void) runEve...