Problems passing array by reference to threads

后端 未结 3 1962
长情又很酷
长情又很酷 2020-12-21 05:16

I\'m learning threading and I\'ve found some simple examples.

What I\'m hoping to do is create 5 threads, that each assign a random number to an array of 20 int\'s.

3条回答
  •  春和景丽
    2020-12-21 05:48

    The other answers cover the main points: there's another one that is often an issue (at least on LINUX: not sure about windows)

    int array1[1000000];
    int array2[1000000];
    

    Declaring very large arrays as local variables runs the danger of overflowing your stack space, thus crashing your program.

提交回复
热议问题