multithreading

Java: (Threads/Timer) Run a function everyday at say 6AM

Hello Everyone I have my application on Windows platform and want a java function to be executed everyday at some particular period of time. Need some guidance how to go about it. Have already looked for some previous posts but need some understanding of which method to use and how? Thanks. ...

using .NET 4 Tasks instead of Thread.QueueUserWorkItem

I've been reading bunch of articles regarding new TPL in .NET 4. Most of them recommend using Tasks as a replacement for Thread.QueueUserWorkItem. But from what I understand, tasks are not threads. So what happens in the following scenario where I want to use Producer/Consumer queue using new BlockingCollection class in .NET 4: Queue i...

How To Create Resource Manager for Multi-Threaded Environment?

I have a pool of connections. The exact nature of them isn't particular important in this case - think of them like primitives that can be passed around freely. In a multi-threaded environment, I want to create a resource manager on which I can call "acquire()" to gain exclusive access to a connection in a thread, and subsequently "relea...

C++ TLS, somethings wrong...

I'm learning about Thread Local Storage... (TLS) Here is my TLS Alloc code: //global variable DWORD g_dwTlsIndex; //inside DLLMain: int val= 5; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: g_dwTlsIndex = TlsAlloc(); if ((g_dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) { printf("No more indexes available"); } ...

python multiprocessing - text processing

hi, I am trying to create a multiprocessing version of text categorization code i found here (amongst other cool things). I've appended the full code below. I've tried a couple of things - tried a lambda function first, but it complained of not being serializable (!?), so attempted a stripped down version of the original code: negi...

Android game thread lifecycle implementation

Hello SO, So I am working on a new basic 2d game for Android and was setting up my usual implementation of a game thread working with a SurfaceView. While typing away, I realized that, while this seems to work, I would really like to know if there is a better way to achieve the same results. Here are the basics of what I do right now (I...

Android: notifyDataSetChanged() not updating listview after orientation change

Hello all, I have a semi-complicated problem and hoping that someone here will be able to help me. On a click event I create a thread and start a long-running operation based on this method. After the long-running task is completed, it does a callback to another method, which does a post to the handler: @Override public void content...

Reading/writing of reference typed field by multiple threads WITHOUT lock

Context: highly threaded server-side application with many reads, occasional writes. Let us consider the following simple code: [Serializable] public class BusinessObject { // ... lot's of stuff, all READ ONLY!!! } public class BusinessObjectHost { private BusinessObject bo; public BusinessObject BO { get { retu...

PostThreadMessage to another process

I want to post a message to a thread that is running as another process (in particular as a windows service). I've read the documentation for PostThreadMessage but there are some things unclear for me. How do I get a handle for my service's thread? The system only does marshalling for system messages (those in the range 0 to (WM_USE...

Thread creation time on windows xp

Can any one help me in identifying the total time consumed while creating a thread and deleting a thread on windows xp, assuming the same configurations. Thanks. ...

Can WaitHandle.WaitOne with ExitContext flag be used without ContextBoundObject class?

MSDN documentation suggests that there may be other ways of using ExitContext flag. See WaitHandle.WaitOne() What other ways are there to enter a non-default context outside of using a ContextBoundObject inherited class? (I can't use ContextBoundObject in my application) ...

Confused, are languages like python, ruby single threaded? unlike say java? (for web apps)

I was reading how Clojure is 'cool' because of its syntax + it runs on the JVM so it is multithreaded etc. etc. Are languages like ruby and python single threaded in nature then? (when running as a web app). What are the underlying differences between python/ruby and say java running on tomcat? Doesn't the web server have a pool of th...

Java Swing + Threads

Hello! This code draws two lines but waits a second.. I am looking how to do that in a seperate thread so it wont freeze the application.. To draw one line and display it to the user and then the second.. Sorry but i am confused.. found too many solutions public class Askisi2_3 extends JFrame { private class LineJPanel extend...

Having trouble understanding this error creating a thread...

HANDLE hThread; DWORD dwThreadId; hThread = CreateThread( NULL, // default security attributes 0, // use default stack size MyThreadFunction, // thread function name 0, // argument to thread function 0, ...

How do you close an application when some WaitHandle is in the middle of a call to WaitOne?

Is there a standard way to close out an application "cleanly" while some WaitHandle objects may be in the state of a current blocking call to WaitOne? For example, there may be a background thread that is spinning along in a method like this: while (_request.WaitOne()) { try { _workItem.Invoke(); } finally {...

Semaphores in a single thread

Hello, I was wondering whether it would ever make sense to use a mutex or semaphore when there is only one thread?. Thanks for your help. ...

explicit joining of python threads?

I need to start some threads in a python program. The threads perform a background task which might take a long time, so I don't want to block the main thread waiting on the task to happen. Python provides the ability to 'reap' threads using Thread.join() and Thread.isAlive(). But I don't actually care about finding out when the thread ...

How do I concurrently download and convert a binary file using threads?

I have a program that downloads a binary file, from another PC. I also have a another standalone program that can convert this binary file to a human readable CSV. I would like to bring the conversion tool "into" the download tool, creating a thread in the download tool that kicks off the conversion code (so it can start converting whi...

Is there a thread safe queue class for Visual Studio C++ 6.0?

I would like to implement a thread safe queue in VS 6.0 Is there a good class to use for this? This is an MFC application using the CWinApp. My former post lead me to here but I don't have the luxury to code in VS 2010, stuck in 6.0 land. o well..... Thank You. ...

LTS problem problem with the fsb code

Hi this is ma code in the LTSA tool THREAD = (start-> RUNNABLE -> dead->THREAD), RUNNABLE = (yield ->RUNNABLE|NOT_RUNNABLE|THREAD), NOT_RUNNABLE = (RUNNABLE). I get this error : ERROR line:1 - ) expected Anyone know to fix this Many Thanks ...