Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4EE1E200B6C for ; Sun, 14 Aug 2016 04:41:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4D6A4160AB2; Sun, 14 Aug 2016 02:41:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 94C53160AA6 for ; Sun, 14 Aug 2016 04:41:57 +0200 (CEST) Received: (qmail 87522 invoked by uid 500); 14 Aug 2016 02:41:51 -0000 Mailing-List: contact users-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@flex.apache.org Delivered-To: mailing list users@flex.apache.org Received: (qmail 87510 invoked by uid 99); 14 Aug 2016 02:41:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Aug 2016 02:41:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 1BD61C7599 for ; Sun, 14 Aug 2016 02:41:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.049 X-Spam-Level: X-Spam-Status: No, score=-0.049 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=classsoftware-com.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id TcFn1c8r2yT8 for ; Sun, 14 Aug 2016 02:41:47 +0000 (UTC) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id BCFB65F23E for ; Sun, 14 Aug 2016 02:41:46 +0000 (UTC) Received: by mail-pa0-f51.google.com with SMTP id i5so7092062pat.2 for ; Sat, 13 Aug 2016 19:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=classsoftware-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=rIc2bFndP5QnU2aVyc1sYJoROKeUA4e3GjinfODXyKQ=; b=fuwoQk5Rjjjh4UvCdOmIls4OHWsBjAb/r6MZURJrNCJ3kWzAESUYc12m3HIVVSqDJ6 tAGyvmtsgcFeRKKkmIRDFChjw1uvkwao+Yc/Zjw/2aShaOjyt2/lBLfAlrFfZDjkA1iG 9Tr3nH058CL7/k8CkbFLa9YDxMLw5IvxusTzkU8Ql4P18iHzgul3CZ/q4c+DDt+8We8x AOH9JoD1c6GK+V2CzsKFIBxcdoC+i7ANFZa6zGAajzp/HCI1skdK3/LXbP7LtNgMtMs1 d1cxlW8WPVQwytG8O2xREVDC6IgdxiZCJ0HUL8JXCD0bviD6/jzLYcJRB8yVf/5yXHdf EZ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=rIc2bFndP5QnU2aVyc1sYJoROKeUA4e3GjinfODXyKQ=; b=aG3sLspJPbLkXn+xKFYx78GIEqon5anx77wLgiYjKBtxXpgNXIxqFiGHOwRSyVS3E4 sJwV0WmMv1ighn6Ak8ZV8qE/+moVvdcNHKgC/Lv1YX1zgaZCiFBi6j7Kidjra3EMwkZn xFboRsrjXDjuOtpOUSXBaMvHEWYL+Ugiw34FN3bFyfX32/tAmDfQuQbNCyt0ymAeq3c7 hUlMgmPVVZDFGiFYDkXKHH+FbqIlJJy84GBsxhwRzPTSBApg361Du9S3QP7/1U6wOS+O TeHTkiBjxRxrVc0fLPYTdYVOz9rAvnZBOucIZf6Wu3VImeKG43mlYimaYvlB1a7bzAj+ O3mA== X-Gm-Message-State: AEkoous3kLY1ej6ePuiOlPjLe7ochxFmzPyrXSrGeeuKxzuAB2wrSapwb19XtfeoTetkVQ== X-Received: by 10.66.242.201 with SMTP id ws9mr41089499pac.7.1471142505649; Sat, 13 Aug 2016 19:41:45 -0700 (PDT) Received: from [192.168.0.4] (ppp121-44-253-33.bras2.syd2.internode.on.net. [121.44.253.33]) by smtp.gmail.com with ESMTPSA id s89sm23061398pfi.83.2016.08.13.19.41.43 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Aug 2016 19:41:44 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Multithreading From: Justin Mclean In-Reply-To: <1471140026513-13274.post@n4.nabble.com> Date: Sun, 14 Aug 2016 12:41:39 +1000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1471140026513-13274.post@n4.nabble.com> To: users@flex.apache.org X-Mailer: Apple Mail (2.3124) archived-at: Sun, 14 Aug 2016 02:41:58 -0000 Hi, > I am likely to write a simple command line C++ program that gets data = out of > a database, processes it, and then writes the data to a database table = to be > consumed by mobile devices. I am very interested in seeing the speed > difference in processing the same data in C++ versus my AIR = application. Given it a fairly straight forward calculation I=E2=80=99s probably go = with C rather than C++ to avoid some of it=E2=80=99s complexity. It = likely to run faster than in AIR. > I currently know nothing about C++, so I don't know if it is like AIR = and > natively runs in a single thread, or if it somehow takes advantage of > multiple threads on your computer. By default no, in C you need to write code to take advantages of threads = and threads are not part of the language. While reasonably = straightforward [1] it can be a little tricky at times to get = working/debug. > it would be more efficient for me if I was able to run multiple > instances of the C++ application side by side so that I could process > several cities of data at the same time. Not more efficient but it would be simpler. A thread has less overhead = than a process. It is however easier to communicate between threads than = communicate between processes if you need to do that. > I was wondering what happens if you run several instances of a single = threaded application at the same time?=20 The OS will give each of them some time on the number or cores it has. = Remember there also other programs likely to be running at the same time = so you are not going to get 100% of the CPU cores all the time just for = just your code. > Does the OS put each instance in its own thread The OS works at a process level not a thread level. [2] The code works = at a thread level. For a problem like this something like Spark [3] is going to be a more = scalable solution as it can scale over multiple cores and machines. The = problem, basically taking a set of data and filtering it fits the map / = reduce [4] concept quite well. There is however (at a guess) going to be = a significant learning curve here. Thanks, Justin 1. http://www.geeksforgeeks.org/multithreading-c-2/ 2. = http://www.programmerinterview.com/index.php/operating-systems/thread-vs-p= rocess/ 3. http://spark.apache.org 4. https://en.wikipedia.org/wiki/MapReduce