thread-safety

Threading - make sure the thread finishes

半世苍凉 提交于 2019-12-25 03:09:12
问题 SOLVED: http://msdn.microsoft.com/en-us/library/ff431782(v=VS.92).aspx I have the following class that will give me the current location in WP7: public class Position { private GeoCoordinateWatcher watcher = null; public GeoCoordinate CurrentLocation { get; set; } public Position() { ObtainCurrentLocation(); } private void ObtainCurrentLocation() { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs

Java swing UI Threads and event button events

旧城冷巷雨未停 提交于 2019-12-25 02:45:09
问题 So as far as I understood, all the swing components should be created, modified and queried only from the EDT. So if I happen to press a JButton "submit" let's say, that will pack up all the information from the text boxes, send that data to controller and then controller will send it to other controllers which will eventually send stuff to the server. What thread is the action for that button is running on? If it is running on EDT, how do I exit it to send the data to controller from the

Adding data to a hashmap in parallel

℡╲_俬逩灬. 提交于 2019-12-25 02:28:45
问题 I've got an instance of an std::unordered_map serving as a database of some sort. (It's basically just a regular hashmap). I have 4 threads retrieving long strings from a network (I'm using the c++11 std::threads) and within each of those threads, i tokenize the strings they receive. The tokenization itself is paralellized as well using the new Microsoft AMP library (so the process of tokenization is done by the GPU threads). I would like each of the 4 "main" threads to add the tokens as keys

VB.NET Form.Show from another thread hanging form

被刻印的时光 ゝ 提交于 2019-12-25 01:12:41
问题 I have a series of methods being called for my networking code. An event gets fired from the networking thread. Inside this event, which I've hooked into from a singleton class, I route messages to form level methods which they register on form load to handle certain messages they care about. Inside of these form message hooks I need to close the current form (which I was able to do) but also show a different one (which is giving me the trouble). The new form sort of shows but it's hanging

Is the PCRE library thread-safe? If not, which do you recommend?

断了今生、忘了曾经 提交于 2019-12-24 22:10:49
问题 For C/C++, is the PCRE library thread-safe? If PCRE is thread-safe, is there any problem in performance? 回答1: Judging from the PCRE documentation: MULTITHREADING The PCRE functions can be used in multi-threading applications, with the proviso that the memory management functions pointed to by pcre_malloc, pcre_free, pcre_stack_malloc, and pcre_stack_free, and the callout and stack-checking functions pointed to by pcre_callout and pcre_stack_guard, are shared by all threads. The compiled form

Random number generator of L'Ecuyer with Bays-Durham

江枫思渺然 提交于 2019-12-24 19:26:52
问题 I am working with Monte Carlo simulations to find the decimal places of PI. So far so good but OpenMP came in and I realize that ran2, arguably the best RGN, is not threadsafe! The implementation is here. Since I have not worked with OpenMP and neither a lot on multi-threading I am stuck at making this thread safe using OpenMP. So far what I know is that a function is already thread-safe if it doesn't modify non-local memory and it doesn't call any function that does. In this case, there are

Changing Membership.ApplicationName in code - thread safety

我的未来我决定 提交于 2019-12-24 19:16:42
问题 On the MSDN page for the Membership.ApplicationName property (which applies to an asp.net membership provider), it warns that although one can change Membership.ApplicationName in code, 'The ApplicationName property is not thread safe for multiple writes, and changing the ApplicationName property value can result in unexpected behavior for multiple users of an application.' They therefore recommend avoiding using it for a 'web application'. This is because the default SqlMembershipProvider is

Multiple threads acquiring the same monitor?

别等时光非礼了梦想. 提交于 2019-12-24 19:14:34
问题 The question is around the discussion "Multiple Java threads seemingly locking same monitor". In our application, we are facing similar issue. Sometimes the application is running extremely slow. Multiple thread dumps have been captured. The thread dumps indicate that 2/3 threads have acquired the same lock object at the same point of time and are in the BLOCKED state. Other threads (10 to 20 in number at different point of time) are BLOCKED while waiting for the very same lock object. Pseudo

Arc lifetime does not live long enough from clone()

廉价感情. 提交于 2019-12-24 17:08:09
问题 I'm trying to create a parameter structure that will possibly be shared between threads. It has a member called layer_storage which some members will need to mutate. I tried the following code, but am getting an error saying that the cloned Arc does not live long enough. This same member worked fine before the addition of Arc<Mutex<>> . use std::sync::{Arc, Mutex}; #[derive(Clone)] pub struct Params { pub optional: Vec<f32>, } pub struct ParamManager { layer_storage: Arc<Mutex<Vec<Params>>>,

Threadsafe and generic arraylist?

心已入冬 提交于 2019-12-24 15:26:06
问题 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 be possible. 回答1: A little knowledge is a dangerous thing ;-) Yes, you could use Meta-Knight's suggestion and use SyncRoot , but you need to be careful - it's not a panacea.