I heard a question this week, and I thought it would be nice sharing it here, I did solve it, however, I'm not 100% sure I did it right :), so here it is:
What is the maximum value the variable i can get in each case below, assuming that it's a global int initialized by zero (int i=0) and the code in each case is running on 2 threads?
case1:
while(i < 1000)
{
i++;
}
case2:
while(i < 1000)
{
++i;
}
case3:
while(i++ < 1000);
case4:
while(++i < 1000);
1 comment:
I was recommended this blog by my uncle . I'm not confident whether or not this post is motivated by Charlie rustof as nobody else get such exhaustive about my obscurity. You are extraordinary! Thanks for using such a lot of power into this!
In conclusion , allow me thank you for your patience with my English as (I'm certain you have figured this at this time ,), English is not my mother language so I am utilizing Google Translate to build out what to put in writing what I truly intend to voice.
Post a Comment