Differences From Artifact [2fe868045e]:
- File
tests/objc_sync/test.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 1303) [annotate] [blame] [check-ins using]
To Artifact [a058419e78]:
- File tests/objc_sync/test.m — part of check-in [292b83bb90] at 2017-07-02 19:30:09 on branch trunk — Fix tests/objc_sync (user: js, size: 1304) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFString.h" #import "OFThread.h" OFObject *lock; @interface MyThread: OFThread | < | > > | | | | | > > > | > > | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #import "OFString.h" #import "OFThread.h" OFObject *lock; @interface MyThread: OFThread @end @implementation MyThread - (id)main { const char *name = [[[OFThread currentThread] name] UTF8String]; printf("[%s] Entering #1\n", name); @synchronized (lock) { printf("[%s] Entering #2\n", name); @synchronized (lock) { printf("[%s] Hello!\n", name); } printf("[%s] Left #2\n", name); } printf("[%s] Left #1\n", name); return nil; } @end int main() { MyThread *t1, *t2; lock = [[OFObject alloc] init]; t1 = [MyThread thread]; [t1 setName: @"A"]; t2 = [MyThread thread]; [t2 setName: @"B"]; [t1 start]; [t2 start]; [t1 join]; [t2 join]; return 0; } |