【发布时间】:2021-06-24 21:08:20
【问题描述】:
我有一个程序,它有一个主线程和一个第二个线程。第二个线程修改一个全局变量,然后将在主线程中使用。但不知何故,我在第二个线程中所做的更改并没有显示在主线程中。
section .bss USE32
global var
var resd 1
section .text USE32
..start:
push 0
push 0
push 0
push .second
push 0
push 0
call [CreateThread]
mov eax, 1
cmp [var], eax ; --> the content of var and '1' are not the same. Which is confusing since I set the content of var to '1' in the second thread
;the other code here is not important
.second:
mov eax, 1
mov [var], eax
ret
(这是我在循环中创建线程的真实程序的简化;I haven't tested this exact code。)
【问题讨论】:
-
为什么 var 的内容必须是 '1' 此时 ?
标签: multithreading winapi assembly x86 nasm