| |

VerySource

 Forgot password?
 Register
Search
View: 960|Reply: 9

Ask a question about the parameters passed by 2 threads causing the data of 2 parameters to change

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-22 19:00:01
| Show all posts |Read mode
May i create a thread to pass a parameter a [0]
Then I create a thread to pass a parameter a [1], but the content of a [1] has changed at this time. What is the reason?
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-7-1 11:00:01
| Show all posts
Post key codes for arrays and threads to provide more clues
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Belgium

 Author| Post time: 2020-7-2 11:00:01
| Show all posts
That a[] is an array of structures,
A button is used to create a thread and pass one of the a array, and increment.
The structure of a is a pointer to class and a pointer to ClistBox

When the button is clicked for the first time, the program is normal, and the error occurs when the button is clicked the second time.
May I ask what kind of situation can cause such a situation to happen
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-7-4 15:15:01
| Show all posts
Is the array element out of bounds, or caused by memory overflow?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-20 20:15:01
| Show all posts
But there is no hint of memory overflow,
When it is executed for the first time, the data in array 2
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-21 21:09:33
| Show all posts
Array variable life cycle problem
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-7-22 16:30:01
| Show all posts
A button is used to create a thread and pass one of the a array, and increment

What to increment? ?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-24 14:45:01
| Show all posts
When you click the button, see if there is an operation in the thread
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-27 11:15:01
| Show all posts
1. Check where the a[] array is defined, where the value is assigned, and will it affect the value in a[] when the button is clicked.
2. (Important) In the thread function you opened, carefully check whether the pointer passed in is overwritten?
Reply

Use magic Report

1

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-29 10:00:01
| Show all posts
The specific code is posted, everyone see
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list