-
September 24th, 2021, 01:16 AM
#1
need help with threads
Hi, I am newbie to managed c++.
I need a code with main function that four threads run four instances of this class , Animal, simultaneously.
Each instance prints a different animal kind. "cat", "dog", .,.
where to create thread should be at?
Code:
ref class Animal()
{
Animal(String ^s)
{
Console::Writeline(s)
}
// where the create thread should be at?
}
-
September 24th, 2021, 01:26 AM
#2
Re: need help with threads
Victor Nijegorodov
-
September 26th, 2021, 06:04 PM
#3
Re: need help with threads
Works now.
if got a Add function in a shared header:
Code:
int Add(int a, int b)
{
return a+b;
}
is it thread safe if multiple threads calling it?. if not how to make it safe to avoid unexpected results?.
Last edited by @EE@; September 26th, 2021 at 06:06 PM.
-
October 5th, 2021, 11:51 PM
#4
Re: need help with threads
No opinion on the last question?!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|