File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -28,25 +28,27 @@ public func call_foobar() {
28
28
// Test ThreadSanitizer execution end-to-end.
29
29
30
30
import Darwin
31
- var user_interactive_thread : pthread_t ?
32
- var user_interactive_thread2 : pthread_t ?
31
+
32
+ var threads : [ pthread_t ? ] = [ ]
33
33
var racey_x : Int ;
34
34
35
- pthread_create ( & user_interactive_thread, nil , { _ in
35
+ for _ in 1 ... 5 {
36
+ var t : pthread_t ?
37
+ pthread_create ( & t, nil , { _ in
36
38
print ( " pthread ran " )
37
39
racey_x = 5 ;
38
40
39
41
return nil
40
- } , nil )
41
-
42
- pthread_create ( & user_interactive_thread2, nil , { _ in
43
- print ( " pthread2 ran " )
44
- racey_x = 6 ;
45
-
46
- return nil
47
- } , nil )
42
+ } , nil )
43
+ threads. append ( t)
44
+ }
48
45
49
- pthread_join ( user_interactive_thread!, nil )
50
- pthread_join ( user_interactive_thread2!, nil )
46
+ for t in threads {
47
+ if t == nil {
48
+ print ( " nil thread " )
49
+ continue
50
+ }
51
+ pthread_join ( t!, nil )
52
+ }
51
53
52
54
// CHECK: ThreadSanitizer: data race
You can’t perform that action at this time.
0 commit comments