• 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
[Q] Why is the threading and UI updating designed to be done only on a main thread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q] Why is the threading and UI updating designed to be done only on a main thread?


  • Subject: [Q] Why is the threading and UI updating designed to be done only on a main thread?
  • From: JongAm Park <email@hidden>
  • Date: Tue, 13 Mar 2012 14:09:47 -0700

Hello,

While doing projects with Cocoa and Objective-C, I have always thought that allowing UI update only on main thread was a weak point of Cocoa/Objective-C. Especially, when gracefully terminating threads which would be better update some UI stuff and if main thread is required to wait until those threads finishes for clean exit, it can cause dead lock condition. In other words, the thread function may want to update UI like inserting a log message to a text field on a window and thus asking main thread to do so, and main thread is waiting to acquire a lock or waiting using "Join", then either the main thread and the other thread can't progress.

But, I also noticed the same pattern with C# .NET. Unlike Win32/MFC and like Objective-C/Cocoa, it also asks a main thread to update UI widgets.

Is there any reason to design threading and UI update model like this?
At first I thought it was due to somehow Obj-C/Cocoa sticks to some old model, but C# .NET is fairly new architecture. They could have avoided it if doing so was better. So, I guess there must be some reason behind it.

Can anyone explain the rationale behind it?
Also, is there a way to gracefully terminate an app by quitting threads and main thread?

Thanks,
JongAm Park
_______________________________________________

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

  • Follow-Ups:
    • Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
      • From: "Gary L. Wade" <email@hidden>
    • Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
      • From: Scott Ribe <email@hidden>
    • Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
      • From: Brian Lambert <email@hidden>
    • Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
      • From: "Stephen J. Butler" <email@hidden>
    • Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Undomanager for custom object?
  • Next by Date: Re: Undomanager for custom object?
  • Previous by thread: Re: Undomanager for custom object?
  • Next by thread: Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
  • Index(es):
    • Date
    • Thread