multithreading

How to pass object from main thread to another thread in java

In my main application class I have an object of JTextArea(say txtArea). I have created two another threads in main_application program. The two threads I have created is for reading and writing in serial port. Now I want to put the serial port read buffer data into an JTextArea object. So I need to pass the JTextArea object created in m...

Ruby 1.8.6, SQLite3 thread safety.

Is the sqlite3 Ruby gem thread safe? I can't find any documentation to say that it is. In my experiments, accessing a database from multiple Ruby threads eventually leads to the following error: /Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/driver/native/driver.rb:84: [BUG] Bus Error Is there anything I'm missing? If not...

Raising an event thread safely

I'm sure I've seen this around before but I'm wondering how I should raise an event thread-safely. I have a message despatch thread which looks somthing like. while(_messages > 0){ Message msg; // get next message if (MessageDispatched != null) MessageDispatched(this, new MessageDispatchedEventArgs(msg.Msg, msg.Pa...

C#: The best way to use shared resources?

Hi there. I need to serialize access to shared resource(ie Cache). I use pattern described later, but sometimes, especially the first two threads, loads data twice. Where is the problem? public class Entity { } public class CacheManager { public static CacheManager Instance = new CacheManager(); private CacheManager() { _thisLoc...

Debugging multi threaded environment in .net

I have an application that uses background workers. There are places that a background worker starts from a timer tick event. How can I prevent the code from jumping in debug to the timer tick? Should I manage the timer in another thread?? ...

Android: raise AlertDialog from background thread

In my activity there's some stuff going on in a background thread, which gets started in Activity_1. The processing of the background thread takes a while and I want to notify the user when it's completed via an AlertDialog. However, the user might have changed to Activity_2 or Activity_3 in the meantime and I would like to pop up the Al...

Best way to schedule deferred execution of method using ThreadPool?

I have a server application which needs to schedule the deferred execution of method(s). In other words, mechanism to run a method using a thread in ThreadPool after a certain period of time. void ScheduleExecution (int delay, Action someMethod){ //How to implement this??? } //At some other place //MethodX will be executed on a thread...

Python, thread and gobject

I am writing a program by a framework using pygtk. The main program doing the following things: Create a watchdog thread to monitor some resource Create a client to receive data from socket call gobject.Mainloop() but it seems after my program enter the Mainloop, the watchdog thread also won't run. My workaround is to use gobject.t...

Thread context on Delphi

I am creating a server that starts a thread (listening thread). This thread listens for connections and does it's thing. Eventually it may receive some data, that I want to pass to the creator of the server: My program --> Creates my server --> Creates the listener --> Creates a thread for every client Now the question is: if I assign ...

Why does multithreaded file transfer improve performance?

RichCopy, a better-than-robocopy-with-GUI tool from Microsoft, seems to be the current tool of choice for copying files. One of it's main features, hightlighted in the TechNet article presenting the tool, is that it copies multiple files in parallel. In its default setting, three files are copied simultaneously, which you can see nicely ...

Safely iterate an array that can be changed in another thread

I want to safely iterate(not get a collection was changed during iteration) through an array that can be changed by another thread. What's the best way I can do it? ...

What type of java cache should be used in case data changes frequently?

I have a JSP which shows data by many aggregation types. E.g. By market, by category, by server type, etc.. What I have is the data by publisher and time. Publisher is the most granular level of data in my case. Now this data changes on every 1/2 an hour. The number of data per half an hour is almost 5K and anyone at a time looks data ...

How can I know/see on which core a thread run ? (In win XP)

Hi, If I have a multi-thread program, how can I know on which core each thread run ? Is there any another solution for win XP in C# ? I try this: [DllImport("ntdll"), SuppressUnmanagedCodeSecurity] public static extern int NtGetCurrentProcessorNumber(); and I get this exception: System.EntryPointNotFoundException was unhandled ...

How to handle this Multithread situation and don't lock?

Hello, I have this situation: a Form with a System.Timer in it (with AutoReset = False). The form has its main thread and the timer its own thread too (nothing new here). When the user press a button I need to stop the timer, wait until the timer thread has stopped its execution and do something more. On the other side, the timer upd...

Jython How to stop script from thread?

I'm looking for some exit code that will be run from a thread but will be able to kill the main script. It's in Jython but I can't use java.lang.System.exit() because I still want the Java app I'm in to run, and sys.exit() isn't working. Ideally I would like to output a message then exit. My code uses the threading.Timer function to run...

Where can I find benchmarks on different networking architectures?

Where can I find benchmarks on different networking architectures? I am playing with sockets / threads / forks and I'd like to know what the best is. I was thinking there has got to be a place where someone has already spelled out all the pros and cons of different architectures for a socket service, listed benchmarks with code that run...

Is the linux kernel's list.h thread safe?

Is the linux kernel's list.h thread safe? Thanks, Chenz ...

Impossible to make a cached thread pool with a size limit?

It seems to be impossible to make a cached thread pool with a limit to the number of threads that it can create. Here is how static Executors.newCachedThreadPool is implemented in the standard Java library: public static ExecutorService newCachedThreadPool() { return new ThreadPoolExecutor(0, Integer.MAX_VALUE, ...

QGraphicsView/Scene - multithreading nightmare

Am I correct in thinking that the QGraphics* classes are not thread-safe? I am porting an old app to Qt and in the process attempting to make it multi-threaded too. I looked at the update code and I see no locks whatsoever. I started off right, all my processing is done in a set of worker threads so that the GUI does not have to block. ...

Alternative to interrupt_main() in Jython?

Whenever the code thread.interrupt_main() is used in Jython it doesn't actually interrupt the main thread. Any ideas as to alternatives? Code is below: import threading import dummy_thread as _thread def exitFunct(): _thread.interrupt_main() t = threading.Timer(60.0, exitFunct) t.start() for i in range(1, 3000): print i ...