Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #533

Re: Thread Safety of "this" pointer

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Sergei Organov <osv@javad.com>
Newsgroups comp.programming.threads
Subject Re: Thread Safety of "this" pointer
Date Mon, 05 Sep 2011 21:46:38 +0400
Organization Aioe.org NNTP Server
Lines 27
Message-ID <j431tr$8e6$1@speranza.aioe.org> (permalink)
References <j40c4l$gnt$1@dont-email.me>
NNTP-Posting-Host FbqE4bp6pnBMv2gXDPVl+g.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Complaints-To abuse@aioe.org
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.programming.threads:533

Show key headers only | View raw


ittium <ittium@gmail.com> writes:

> Group,
> There is a base class B and Two derived class D1 and D2. b is
> **shared** base class pointer. While d1 and d2 are derived class
> pointer
>
> thread 1
> --------
> *b=d1;
> b->execute();
>
> thread 2
> --------
> *b=d2;
>
> Should I protect (using mutex) the above code. Since this pointer will
> change during the processing
> thanks
> Ittium

Yes, you should implement protection to the above code, but no, 'this'
pointer won't be changed during processing. It's contents of the
variable to which 'b' points that will be changed, and it's that
contents you need to protect (using mutex).

-- Sergei.

Back to comp.programming.threads | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Thread Safety of "this" pointer ittium <ittium@gmail.com> - 2011-09-04 22:52 +0530
  Re: Thread Safety of "this" pointer David Schwartz <davids@webmaster.com> - 2011-09-04 15:31 -0700
    Re: Thread Safety of "this" pointer itt ium <ittium@gmail.com> - 2011-09-05 01:43 -0700
      Re: Thread Safety of "this" pointer ycwang <wangyongcong@gmail.com> - 2011-09-05 03:21 -0700
  Re: Thread Safety of "this" pointer Sergei Organov <osv@javad.com> - 2011-09-05 21:46 +0400

csiph-web