Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 915535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:54:15+00:00 2026-05-15T17:54:15+00:00

Is it safe to for example do: void AddTwo(int &num) { num +=2; }

  • 0

Is it safe to for example do:

void AddTwo(int &num)
{
  num +=2;
}


void ThreadProc(lpvoid arg)
{
AddTwo((int)arg);

}

Would it be safe for this to occur if 4 threads were doing this at the same time? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:54:16+00:00Added an answer on May 15, 2026 at 5:54 pm

    The function itself is safe to call. It becomes dangerous if they’re all trying to operate on the same variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is the following code safe? class B { public: int& b; B (int& _b)
I'm wondering whether static constant variables are thread-safe or not? Example code snippet: void
In this example: @interface something : something { NSString *saveString; } -(void)saveStringForLater:(NSString*)myString { //do
Is a C# struct thread-safe? For example if there is a: struct Data {
Say I have a function: void someFunc(int *x,int count); which is out of my
This outputs F~ but I was expecting ~F #include <iostream> struct Foo { int
This is closely related to Is it safe to signal and immediately close a
Are the basic arithmetic operations Thread safe? For example, if there is ++ operation
I would like some advice on safe ways to deal with struct's when the
Look at the following example: string foo(int i) { string a; ... Process i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.