Hi,
Let's say that we want to make class A thread-safe using an std::mutex. I am having my copy constructor and assignment operator similarly to the code below:
#include <mutex>
class A {
private:
int i;
mutable std::mutex mtx;
public:
A() : i(), mtx() { }
A(const A& other) : i(), mtx()
{
std::lock_guard<std::mutex> _l...
Is there a way in objective C that I can define a static int that is thread safe?
for example if I have class called Session that has:
static unsigned int session_id = 1000;
- (int) generateSessionID{
return session_id++;
}
I am constructing session objects from different threads, each session object
should have a unique id...
Can I, without locking, safely call List.AddRange(r) from multiple threads? If not, what sort of trouble would I run into?
...
Hi;
When implementing a thread safe list or queue; does it requaired to lock on List.Count property before returning the Count i.e:
//...
public int Count
{
lock (_syncObject)
{
return _list.Count;
}
}
//...
is it nessesary to do a lock because of the original _list.Count variable maybe not a volatile variable?
T...
i want to return selected item from comboBox in separate thread ? win application ( c# )
error message:
Cross-thread operation not valid: Control 'comboBox3' accessed from a thread other than the thread it was created on.
any one can help me plz ......
...
I know there are lot of ways to implement a thread safe singleton pattern like (Double Check Locking , static readonly method, lock method) but i just tried below code
static void Main(string[] args)
{
for (int i = 0; i <= 100; i++)
{
Thread t = new Thread(new ParameterizedThreadStart(doSome));
t.Star...
I am creating window in another thread. After closing the thread some of the resources window is not released from the memory. Because of this growing counter GDI Objects and User Objects in windows task manager. Graphics that not released are font and region. I haven't idea what is going on...
public class WaitingWindowManager
{
pr...
I am trying to write a webserver that processes requests from multiple clients simultaneously. The way it is designed, only one request can be processed at a time.
What I need is a way to call nextPendingConnection() and then dispatch the connection to a separate thread for processing.
Is there any way to do this?
...
Hello
I was wondering, if i have a multi-core processor and i have multiple threads,is it possible that the program will crash if 2 or more threads access a variable at the same time? How can i block temporarily a variable so that simultaneously access is restricted?
Regards,
Alexandru Badescu
...