flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Mclean <jus...@classsoftware.com>
Subject Re: Multithreading
Date Sun, 14 Aug 2016 02:41:39 GMT
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’s probably go with C rather than C++ to
avoid some of it’s 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? 

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-process/
3. http://spark.apache.org
4. https://en.wikipedia.org/wiki/MapReduce


Mime
View raw message