• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Exact semantics of NSThread executation states?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exact semantics of NSThread executation states?


  • Subject: Re: Exact semantics of NSThread executation states?
  • From: "Glenn L. Austin" <email@hidden>
  • Date: Tue, 12 Jul 2016 17:05:43 -0700

> On Jul 12, 2016, at 2:52 PM, Sean McBride <email@hidden> wrote:
>
> Hi all,
>
> NSThread has at least 3 execution state properties: executing, finished, cancelled.  Alas, the docs don't say much about what they mean beyond circular definitions like "A Boolean value that indicates whether the receiver is executing".
>
> I have code where I create an NSThread, add a runloop source, then invoke "start" on the thread.  I have assumed that once I invoke "start" that "isExecuting" should give YES.  Literally:
>
> 	[myThread start];
> 	assert([myThread isExecuting]);
>
> On 10.11.5 and earlier this *seems* to always be true, but on 10.12b2 it's not.  I'm trying to understand if my assumption was wrong or if it's an OS bug.

There's no guarantee that a thread will be running at exit of -[NSThread start] -- only that it has been scheduled for execution. The lower-level pthread APIs also don't guarantee that the thread will start executing when the thread is created.

In reality, there's a fourth state -- scheduled -- that comes before executing.  Most of the time you don't need to worry about it.

--
Glenn L. Austin, Computer Wizard and Race Car Driver         <><
<http://www.austinsoft.com>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Exact semantics of NSThread executation states? (From: Sean McBride <email@hidden>)

  • Prev by Date: Exact semantics of NSThread executation states?
  • Next by Date: UINavigationBar transition
  • Previous by thread: Exact semantics of NSThread executation states?
  • Next by thread: UINavigationBar transition
  • Index(es):
    • Date
    • Thread