multithreading

Calling a function from a function pointer in Delphi

I'm trying to build a generic worker thread in Delphi, one that I can pass a function/procedure (doesn't matter) as an argument and let it execute. My guess is to add a field in the TThread class and call it from TThread.Execute. So the code outside the thread is gonna be: MyThread := TWorkerThread.Create(True); Mythread.CallBac...

Multi threading with Java Executor

Hi, I am stuck with this following problem. Say, I have a request which has 1000 items, and I would like to utilize Java Executor to resolve this. Here is the main method public static void main(String[] args) { //Assume that I have request object that contain arrayList of names //and VectorList is container for each request...

Using pthread_create stops my method from working. Why? Using C.

I have a method which is is meant to write information into a struct. I want to make it run as a thread. If I call it by itself, as childWriter((void*) &sa) it works. If I call pthread_create(&writerChild, NULL, childWriter, (void*) &sa), it no longer works. It doesn't write to the shared object. This is driving me mad. Why isn't it w...

Are there any non-obvious dangers in using threads in ASP.NET?

This is something of a sibling question to this programmers question. Briefly, we're looking at pushing some work that's been piggy-backing on user requests into the background "properly." The linked question has given me plenty of ideas should we go the service route, but hasn't really provided any convincing arguments as to why, exac...

What is the best approach for WPF Multi Threading.

Hello EveryOne, I am using WPF Standalon application and at the login time we are loading complete Chart of Account List. so it will take a time so we were use the thread like ThreadStart dataDownloadThread1 = delegate { Dispatcher.BeginInvoke(DispatcherPriority.Send, (EventHandler) ...

Does the WinForms Control.Invoke rule apply to contained objects?

I understand that multi-threaded WinForms apps are required to use Control.Invoke or Control.BeginInvoke when accessing a control from a thread other than the UI thread. But does this rule also apply when manipulating objects that are contained within a control but which do not derive from the Control base class? For example, when usin...

Multithreading help, yet again (winForms)

I have developed an application that pulls X amount of records from my database per X amount of threads. Each thread then iterates the collections that are created and does some data validation for each record. Once a record is validated / not validated by the application it is updated in the database as being valid / not valid. Records...

Questions about multi-threading

If I have a that thread: Thread sendMessage = new Thread(new ThreadStart(timer.Start())); will, the Tick event of the timer will be on the main thread or on the sendMessage thread? Edit: I have a queue and i want that every x milisecond the timer will tick and the program will dequeue arrays from the queue, but this is my code: Thre...

Memory Fences - Need help to understand

Hello all, I'm reading Memory Barriers by Paul E. McKenney http://www.rdrop.com/users/paulmck/scalability/paper/whymb.2010.07.23a.pdf everything is explained in great details and when I see that everything is clear I encounter one sentence, which stultifies everything and make me think that I understood nothing. Let me show the example ...

is locking necessary for Dictionary lookup?

lock(dictionaryX) { dictionaryX.TryGetValue(key, out value); } is locking necessary while doing lookups to a Dictionary ? THe program is multithreaded, and while adding key/value to dict. dict is being locked. ...

Proper way to pass GUI values to backgroundworker?

I am working with a fairly complex GUI and am trying to pass a lot of data from the GUI to a backgroudWorker. The problem I am running into is accessing some of the GUI values from the background worker. For example, if I try to get ComboBox.Text I get a InvalidOperationException due to cross-threading. However, if I say do TextBox.Text,...

using ConcurrentStack

Hi, I need to use the stack data structure to save strings. But this stack will be accessed from multiple threads. So my question is, how do I use the ConcurrentStack to add data from multiple threads? ...

How to call a method on background thread

Hi all... in my app i am unzipping a zip file(in splash view controller) later i am displaying an image and firing a timer with 4 secs to change image of the previous image view. and later in view did appear i am firing another timer with 10 secs to call next view controller(home view controller).. and there i have a button to go Story ...

WebRequest.BeingGetResponse and IAsyncResult.AsyncWaitHandle not working

WebRequest.BeginGetResponse returns IAsyncResult, which has a member AsyncWaitHandle. Initially, I thought that I could just wait on that in the initiating code. But it turns out that the event is signaled as soon as the request is made and before and not after EndGetResponse is called. This seems unintuitive for me but whatever. So, ...

Win32 alternative for the destructor in pthread_keycreate (when I cannot control dllmain)

In pthreads, you can associate a destructor function with each per-thread storage slot. When a thread dies, if the slot is non-0, the destructor is called. In a Win32 DLL, the DLLMain function, called at thread exit, can do the same thing. What can I do in code that lives in a purely static library? ...

Linux C++ threads are dead, but "hanging" - thread limit

A friend of mine is trying to fix up a custom http server in C++ written for windows to work in Linux. I tried to help him, but all I found seemed too obvious. The app creates a thread for every time a request comes in. The thread serves the request and ends. After some number of requests (something over 300) new threads are not created...

Windows current ThreadID without windows API call

Hey there! I'd like to query the current threadID without making a windowsAPI call. According to this http://en.wikipedia.org/wiki/Win32_Thread_Information_Block wikipedia article it should be possible to access the thread ID directly. I tried this code: void* tibPtr; __asm { mov EAX, FS:[0x18] mov [tibPtr], EAX } int* ptr...

java object serialization - thread safe ?

Hi, I am writing highly concurrent application, which is extensively modifies objects of MyClass. The class is composed of several fields. My question is how to prevent modifications of particular object during its serialization by another thread? Regards, Matt ...

Translate `thread.start_new_thread(...)` to the new threading API

When I use the old Python thread API everything works fine: thread.start_new_thread(main_func, args, kwargs) But if I try to use the new threading API the process, which runs the thread hangs when it should exit itself with sys.exit(3): threading.Thread(target=main_func, args=args, kwargs=kwargs).start() How can I translate the cod...

Android threaded conversation view

What would be the best way to go about designing a threaded conversation view like the one we see in the messages app? I'm not that familiar with the layout views in Android so any help is appreciated. ...