multithreading

Should threads in Java be named for easier debugging?

What are the best practices around thread naming in Java? Are there any naming conventions to follow? ...

How to handle setDelegate: when using multipe threads

Hi all, I've come across an issue with using a third party library, and am not sure what the common pattern to solve it is. I'm using the asi-http-request class, which fetches http objects asynchronously using a thread. In my objects dealloc() method, I do [request setDelegate:nil]; [request release]; However the delegate is someti...

Python threads in embedded Python: How?

While experimenting with Python's (python.org) C API, I found myself wondering how to properly spawn threads via Python's threading package when Python itself is embedded in a C program. Functions PyEval_EvalCode and kin appear to terminate threads it "owns" as soon as the C function finishes evaluating a block of Python code. Roughly, r...

Java GUI threads - SwingWorker

I have a question regarding SwingWorker and Java GUI's. I have several classes which process information, we can call them Foo1, Foo2, and Foo3. This processing can take a very long time. These are all subclasses of Foo, however Foo is not called directly itself (the Foo[x] classes use methods inherited from Foo. In order to keep the...

Invoke a delegate on the main thread in a tiered architecture

I have a background process that i want to regularly maintain the state of gps location. I am not clear on how to invoke a delegate on the main thread in the ui layer when the threaded method is in another class. Here is sample code. My form launches the thread on load: public partial class MainScreen : Form { . . // form st...

How to unit test a class using System.Windows.Threading.Dispatcher

How do I unit testing a class which makes use of System.Windows.Threading.Dispatcher? I am following the MVVM pattern in the setting of WPF. As part of this I am creating a DispatchingBlah class following the pattern used for DispatchingQuoteSource that I saw in this video (see 1:06:16 ish). I want to test that my class has queued the...

Do two synchronized methods execute simultaneously.

I have 4 methods (m1,m2,m3 and m4) in a class. m1,m2 and m3 are synchronized method. Also i have 4 threads t1,t2,t3 and t4 respectively. If t1 access the m1 method (synchronized method), could t2 thread access m2 method (synchronized method) simultaneously? If not what would be the state of t2 ? ...

"pure virtual method called" when implementing a boost::thread wrapper interface

Hi, I have a small wrapper which centralize what's relative to threads : class Thread { protected: boost::thread *m_thread; virtual void work() = 0; void do_work() { work(); } public: Thread() : m_thread(NULL) {} virtual ~Thread() { catch_up(); delete m_thread; } inline void c...

Blackberry thread hanging on SQLite statement prepare

Hi Gurus. I'm developing an application that implements an EditField in which you can type a word and while typing the application will filter the contents that are being shown on screen. For this, I'm starting a new thread when the user types. This thread extracts the information from a SQLite table and then shows it on the UI. I use...

Odd (loop / thread / string / lamda) behavior in C#.

I have a snippet of code that I though should work because of closures. However the result proves otherwise. What is going on here to not produce the expected output, one of each word. Code: string[] source = new string[] {"this", "that", "other"}; List<Thread> testThreads = new List<Thread>(); foreach (string text in source) { tes...

adding a trailing comma to a print command makes threads executions "serialized"

without dumping tones of code here is the symptom having a threads which all run various methods of the same type of object. within the methods i have a print line which reads: print self.args, self.foo everything works just fine. However, if i turn that line into: # remain in the same line print self.args, self.foo, execution is...

Background Worker C# winform

is it a bad idea to load everything in from the background worker?? Current code is Executed on Form_load. we are pulling a lot of data from webservice. some long running works are in background worker. would it be a bad idea to load everything from background worker no matter how small or big the code is?? every function to run in bac...

Threading in XNA

I have a game in XNA which needs to do network calls. In the update method I determine what needs to be sent and then add it to a list of stuff to send. Then I run the network call. This slows down the application alot obviously. So I first tried creating a new thread like this in the update to make it do it on a seperate thread: Thread...

Do g++ thread-local variables follow default initialization rules?

Using g++ to declare function-static thread-local storage: void f() { static __thread somePodStruct thing; ... } can I assume that thing will get zero-initialized? ...

Displaying and refreshing my picture every 5 seconds

Ok, I've got the GUI in tkinter working, and I'm trying to grab and image every 5 seconds and display it in a Label named Picturelabel. from Tkinter import * from PIL import ImageGrab import cStringIO, base64, time, threading class PictureThread(threading.Thread): def run(self): print "test" box = (0,0,500,500) #x,x...

How to use an uncaught exception handler for a multi-thread test in junit?

I have the following code that I expect to run successfully to completion but the code fails at the line "fail("this should not be reached");". Can someone please explain why the default uncaught exception handler is not called: public class UncaughtExceptionTest extends TestCase implements UncaughtExceptionHandler { private f...

In TCP MultiThreaded Server, if a client gets service ,how to find the port number of servicing socket?

In TCP Multi Threaded Server, if a client gets service ,how to find the port number of servicing socket? From sun java tutorials When a connection is requested and successfully established, the accept method returns a new "Socket object" which is bound to the same local port and has it's remote address and remote port set to that of th...

Thread crashed with locked Mutex

Hi, There is scenario, i have two threads both are using same mutex. One thread locked the mutex and crashed. What would be the mutex state? It still locked and second thread never own that mutex? Means a deadlock situation? Thanks in advance. ...

Thread safety in Python (Question how it works)

I've read through the documentation on threading for python and as I've pereceived it the following should hold true: You can access (read) any PoD or python specific object (such as an array) without causing failure in a multi-threaded program trying the same thing at the same time, but you can not change them and accept thread integrit...

boost::thread build error (unable to link lib && unresolved external)

Hi all, I'm trying to follow a simple tutorial of Boost::Thread (ver 1.4-3) in VS 2008: #include <boost/thread/thread.hpp> void Func() { // Do something } void main() { boost::thread _thrd(&Func); _thrd.join(); .... } During compilation it produces this error: Error 1 fatal error LNK1104: cannot open file 'libboost...