Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use NSLock



Dear list!

Can some please explain how I use NSLock to protect a variable from being
used or destroyed by another thread?

My app have 2 threads and a readProc. The normal thread that is always
there and a second thread that starts when I want to request a sysex dump
from my synthesizer.

The variable 'sysexcounter' is used in 2 places.

1 - 'sysexcounter' is incremented In my readProc that get the MIDI bytes

2 - In my second thread my app waits for 'sysexcounter' to get a predefined
value that is the size of my sysex message before the code flow continues.

But it seems that something happens that makes 'sysexcounter' useless. So I
want to protect it from being used by 2 places at the same time. I think
that is the right way to explain my problem. 

Best regards Peter

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.