I'm constructing a framework in Java that will listen for events and then process them in Jython. Different event types will be sent to different scripts.
Since jython takes quite some time to compile the script when PythonInterpreter.exec() is called, I will have to pre-compile the scripts. I'm doing it the following way:
// initiali...
Let's say I have an exposed interface as such:
interface IMyService
{
MyResult MyOperation();
}
This operation is synchronous and returns a value.
My implemented interface has to do the following:
Call an asynchronous method
Wait for event #1
Wait for event #2
This is due to a 3rd party COM object I am working with.
This co...
In the example code
void foo()
{
static Bar b;
...
}
compiled with GCC is it guaranteed that b will be created and initialized in a thread-safe manner ?
In gcc's man page, found the -fno-threadsafe-statics command line option:
Do not emit the extra code to use the
routines specified in the C++ ABI for
thread-safe initiali...
Hello community,
I want to have a generic thread safe collection and I saw that the Arraylist can easily be used thread safe by its static Synchronized method but what bugs me is that this ArrayList is not generic so when I want to use my objects I always have to cast them. Is there an easier way to do this? Also other list types would ...
In Objective-C, you can declare a block as being synchronized on some object by using the @synchronized construct. It would look something like this:
@synchronized (self) {
// Do something useful
}
However, I'm curious what exactly self is referring to when you have a static method (+ instead of -). I tried looking through the App...
I've tried using the examples from MSDN for this but they seem to only be applicable to Windows Forms. For instance the method of using .InvokeRequired relies on the windows forms control, however this method isn't available for WPF controls. The Backgound worker method throws an InvalidOperationException as well -
The calling threa...
How to properly synchronize this? At the moment it is possible thatSetData is called after e.WaitOne() has completed so d could be already set to another value. I tried to insert locks but it resulted into a deadlock.
AutoResetEvent e = new AutoResetEvent(false);
public SetData(MyData d)
{
this.d=d;
e.Set(); // notify that ne...
I need to log to a file because the customer doesn't have a console of something where I can log to with log4net.
Now I read that the FileAppender is not thread safe. Is there anyhow a way to log to file within an app that logs out of different threads or what would be a common alternative?
...
Good aftenoon,
I created a super simple console app to test out the Enterprise Library Caching Application Block, and the behavior is blaffling. I'm hoping I screwed something that's easy to fix in the setup. Have each item expire after 5 seconds for testing purposes.
Basic setup -- "every second pick a number between 0 and 2. if th...
I am trying to make a Java application thread-safe. Unfortunately, it was originally designed for a single-user mode and all the key classes are instantiated as singletons. To make matters worse, there is a whole bunch of interfaces working as constants containers and numerous static fields.
What would be considered as a good practice in...
Hello, I am running into a bit of difficulty using the threadpool class and an array of ManualResetEvents. Below is a simple example of what I am doing. The problem is that in the DoWork method I am getting null references to the resetEvent[param as int] object.
Can't seem to figure what I'm doing wrong.
(edit: got the code block worki...
I have a .NET module that I need to call from an instantiated class. Can I count on only one object at a time being able to access the functions in a module (something like instantiating a module) or will I need to look at locking within the class? I can't seem to get a clear answer to this anywhere. Thanks!
...
What is this:
synchronized (this) {
// ...some code...
}
good for?
(Could you write an example?)
...
I'm very new to multi-threading and for some reason this class is giving me more trouble than it should.
I am setting up a dictionary in the ASP.net cache - It will be frequently queried for individual objects, enumerated occasionally, and written extremely infrequently. I'll note that the dictionary data is almost never changed, I'm pl...
I have a launchd daemon that every so often uploads some data via a web service using NSOperationQueue.
I need to be able to persist this data, both so that it can later be re-uploaded in the event of failure, even between sessions (in case of computer shut down, for example).
This is not a high load application, it probably receives i...
An instance of System.Net.Sockets.Socket
can be shared by 2 threads so one use the send() method and another it's receive() method ?
Is it safe?
Well, I need it to be not only thread-safe, but also that the send/receive methods be non-syncronized, so as to let each thread call them concurrently.
Do I have another way of doing it ?
T...
I consider myself aware of the concepts of threading and why certain code is or isn’t “thread-safe,” but as someone who primarily works with ASP.NET, threading and thread safety is something I rarely think about. However, I seem to run across numerous comments and answers (not necessarily for ASP.NET) on Stack Overflow to the effect of “...
I am using log4net in a class with multiple threads and I had a simple question. Do I need to enter readlock/writelock when checking properties and calling methods on the log4net.ILog interface?
I am using the suggested method from the log4net examples so at the top of said class I have:
Private Shared ReadOnly log As log4net.ILog = ...
I am writing a C# application.
I have (a kind of) logging class. and this logging class will be used by many threads.
How to make this class thread safe?
Should I make it as singleton?
what are the best practices there?
Is there a document that I can read about how to make it thread-safe?
Thanks
...
I am really confused on how these 2 collections behave in multithreaded environment.
Hash table is synchronized that means no 2 threads will be updating its value simultaneously right?
...