i have a service application, which maintains a record of each and every USB being used in the windows system.
in brief, my problem is with the hashmap values getting corrupted in between two threads. one thread picks the database path where values are to be written and other thread writes into that database path.
Service crashes at the, when the below codes are executed.
The first thread fetches the values and the values are sent to the second thread so that it can write the necessary things to the fetched value which is the path of the database. but the hashmap value crashes at some point due to which the service crahses at above code executions.
i am not able to identify the exact reason, as to why the value of ThreadMutexMapPrimary changes or crashes when it is called from the second thread???
i am attaching the code below, with declarations and values i received while debugging.
Containers are typically not thread safe out of their own. This is because most of the time it will just add overhead.
You will need to assure proper synchronised access to any variable/class instance that is read from one (or more) thread and is being written to from one other (or more) thread.
Any such variable typically also needs to be marked as volatile or the compiler could optimise away necessary changes other threads need to see.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.