• 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: Why multi-threading ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why multi-threading ?


  • Subject: Re: Why multi-threading ?
  • From: "Dennis C.De Mars" <email@hidden>
  • Date: Tue, 27 May 2003 08:27:11 -0700

On Tuesday, May 27, 2003, at 07:11 AM, Oscar Morales Vivs wrote:

On Tuesday, May 27, 2003, at 14:21 Europe/Madrid, Greg Weston wrote:

On Tuesday, May 27, 2003, at 01:00 AM, Dennis C.De Mars wrote:

I think multi-threading is probably overused, because developers want
to use it and minimize in their minds the problems it can introduce.
The main problems are:

1) The simple presence of multiple threads greatly increases the
difficulty of writing correct code.

I think it would be more precise to state that the simple presence of multiple threads greatly increases the difficulty of debugging incorrect code.

OK, but that I think that is what I was saying in my point 2. To clarify why I believe point 1 above -- if the threads are truly disjoint and never access the same data or try to communicate with each other, then it isn't much harder to write correct code than in the single threaded case; however, if the threads communicate in any way, operate on shared data or have to synchronize at any point, then it becomes difficult because you have to be aware at every point that between every line of your code, or even within execution of a single line, other code can be executing that can affect the validity of the thread you are currently writing. Of course, there are mechanisms to protect critical code segments, etc., which is what you use to write correct code. The thing that can make it difficult (in my experience) is making sure you use these mechanisms at every single point they are required to be used.

I should add, for the benefit of everybody disagreeing with this point, that most of my "bad experiences" with multi-threading came from a project where I had to support a library of communications routines for use in multi-threaded applications. In other words, the library itself had to be thread-safe, and at the same time the threads couldn't be totally independent (multiple threads could be sending messages to the same destination, for instance, and that had to be handled). Possibly, it is harder to write a thread-safe library than it is to actually write a threaded application.

- Dennis D.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Why multi-threading ? (From: Oscar Morales Vivó <email@hidden>)

  • Prev by Date: Re: NSTextView/NSMutableArray problem!
  • Next by Date: Rootless, complex NSOutlineView?
  • Previous by thread: Re: Why multi-threading ?
  • Next by thread: Re: Why multi-threading ?
  • Index(es):
    • Date
    • Thread