A
Abubakar
Hi,
(me using visual c++ 2005, all native/unmanaged).
So my question is about allocating memory in one thread and using it in
another.
I think its good to explain as following :
Somewhere I have this:
someclass * _obj;
thread_proc1() //used by thread1
{
// this thread does the following:
_obj = new someclass();
.......
// thread exits, but does not delete _obj....
}
thread_proc2() // used by thread 2
{
/* this thread starts later on and plays around
with _obj object that was allocated in thread 1 */
}
I want to know is all this ok? I just had a confusion that bcuz the _obj
variable was declared in thread1 I may have some problem accessing it in
thread 2 after thread 1 is finished. But on the other hand I thought that
since _obj was allocated in the process heap, which wont deallocate when
thread1 exits, so it should be ok for thread 2. And thread 2 can even delete
it. Am I write in thinking of the process's heap this way?
Regards,
Ab.
(me using visual c++ 2005, all native/unmanaged).
So my question is about allocating memory in one thread and using it in
another.
I think its good to explain as following :
Somewhere I have this:
someclass * _obj;
thread_proc1() //used by thread1
{
// this thread does the following:
_obj = new someclass();
.......
// thread exits, but does not delete _obj....
}
thread_proc2() // used by thread 2
{
/* this thread starts later on and plays around
with _obj object that was allocated in thread 1 */
}
I want to know is all this ok? I just had a confusion that bcuz the _obj
variable was declared in thread1 I may have some problem accessing it in
thread 2 after thread 1 is finished. But on the other hand I thought that
since _obj was allocated in the process heap, which wont deallocate when
thread1 exits, so it should be ok for thread 2. And thread 2 can even delete
it. Am I write in thinking of the process's heap this way?
Regards,
Ab.