由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++并发和Java并发有多大区别?
相关主题
core java里有跟C++ std::async类似的东西吗?嵌入式编程问题
问个double和long double的问题C++多线程和硬件的关系
瓶颈在哪儿?openMP or boost::thread (pthread) for multithreading ?
java笑node的震惊:java 的矩阵操作比 c++ 快?
有人在Java/J2EE项目中用过多线程/concurrent吗?请大牛们帮忙看一段并行c++代码的效率问题
java concurrency时,你们用的callable还是runnable?functional programming?
多线程编程前景如何?请教C++11
新版的 eclipse 有什么大的改进?在图像算法领域,纯java没戏,用java和c++混合编程很恶心
相关话题的讨论汇总
话题: java话题: c++话题: executors
进入Programming版参与讨论
1 (共1页)
A*******e
发帖数: 2419
1
手头两本书都有,从哪本开始比较好?
C++ concurrency in action
Java concurrency in practice
对C++熟悉一些,但Java更流行?不知内容是否大同小异。
c********1
发帖数: 5269
2
大同小异.
concurrency functionality is provided by modern OSs.
C++, java just provides interfaces to access the functionality.

【在 A*******e 的大作中提到】
: 手头两本书都有,从哪本开始比较好?
: C++ concurrency in action
: Java concurrency in practice
: 对C++熟悉一些,但Java更流行?不知内容是否大同小异。

k**********g
发帖数: 989
3

Start with Java Executors.
Learn how to use it just like the Runnable and Callable class.
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/E
For example, if your goal is to write Android programs, (1) Executors is
basically all you need - the only other things you need are (2) thread
safety on Android, and (3) understand when and why you need to call Activity
.runOnUiThread() in some situations
C++ didn't have anything in the standard library comparable to Java
Executors. Design-by-Committee Paralysis, lagging behind Java a whole decade.
However, Boost, Intel TBB and Microsoft PPL are libraries that will enable
functionality similar to Java Executors. They might be included into the C++
standard one day ... but that might be many years or decades down the road.
----
Feel free to skip everything below ... just my ranting.
Here, "concurrent" mostly means "multicore", sometimes means "asynchronous"
/ cooperative multitasking.
"Distributed" mostly means spanning over many machines, along with
complications such as high latency, machine failures, network failures etc.
For beginners, this diagram will give an intuitive understanding and
motivation for concurrency: http://cdn.nginx.com/wp-content/uploads/2015/06/Thread-Pool1.png
1. Introduction to computer architecture (talks about how CPU works, e.g.
fetch decode read execute write, CPU cache, etc.)
* Most CS & CompEng should have taken this course in undergrad. If you have
never taken this course, you may have difficulty understanding fundamental
"thread-safety" concepts, because you will not intuitively identify what
kind of memory (variable) accesses will suffer from race-condition.
2. Operating Systems
* Using threads
* Synchronization primitives
* This course should also teach fundamental "thread-safety" concepts.
2. Concurrent data structures and algorithms
* Beginners only need to know the concurrent queues and vectors, know which
of their operations are thread-safe (consistent when used simultaneously by
multiple threads), and why.
* Stay away from the advanced courses ... implementation is too difficult
to learn.
3. Distributed information systems
* Only need to know how to use libraries ...
4. Distributed algorithms
* Too theoretical (e.g. graph algorithms) typically not needed unless
working for the top famous companies
5. Software patterns for multicore computations.
* Single machine (or a single cluster that behaves like a single machine),
many "processing elements" a.k.a. cores.
* Workload is mostly computational, i.e. don't depend on networks, external
resources, or databases.
* Basically the picture above -
* Break down algorithms into "tasks" and specify their "computation order
dependencies"
* Submit read-to-execute tasks to a task queue
* Many worker threads pull from the task queue and execute each item
* Whenever a task is completed, other tasks which had their preconditions
fully satisfied will also be appended to the task queue
* Might also need to know SIMD, GPGPU stuff ... depending
6. Software patterns for distributed computations.

* Hadoop
7. Concurrency practicum
* http://docs.oracle.com/javase/8/docs/api/java/nio/channels/Selector.html
* http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html

【在 A*******e 的大作中提到】
: 手头两本书都有,从哪本开始比较好?
: C++ concurrency in action
: Java concurrency in practice
: 对C++熟悉一些,但Java更流行?不知内容是否大同小异。

h****r
发帖数: 2056
4
your understanding to concurrent is not right, although close.

Activity
decade.

【在 k**********g 的大作中提到】
:
: Start with Java Executors.
: Learn how to use it just like the Runnable and Callable class.
: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/E
: For example, if your goal is to write Android programs, (1) Executors is
: basically all you need - the only other things you need are (2) thread
: safety on Android, and (3) understand when and why you need to call Activity
: .runOnUiThread() in some situations
: C++ didn't have anything in the standard library comparable to Java
: Executors. Design-by-Committee Paralysis, lagging behind Java a whole decade.

c*********e
发帖数: 16335
5
当然是java. 书里面讲到很多java具体的class,有具体的例子。

【在 A*******e 的大作中提到】
: 手头两本书都有,从哪本开始比较好?
: C++ concurrency in action
: Java concurrency in practice
: 对C++熟悉一些,但Java更流行?不知内容是否大同小异。

c*********e
发帖数: 16335
6
正在看Java concurrency in practice,作者是geek,programming技术可能还行,写书
讲故事的水平真不敢恭维,经常看得我有拍桌子的冲动。

【在 A*******e 的大作中提到】
: 手头两本书都有,从哪本开始比较好?
: C++ concurrency in action
: Java concurrency in practice
: 对C++熟悉一些,但Java更流行?不知内容是否大同小异。

k**********g
发帖数: 989
7

async 当中,有扯蛋的成份。

【在 h****r 的大作中提到】
: your understanding to concurrent is not right, although close.
:
: Activity
: decade.

1 (共1页)
进入Programming版参与讨论
相关主题
在图像算法领域,纯java没戏,用java和c++混合编程很恶心有人在Java/J2EE项目中用过多线程/concurrent吗?
c++这种语言注定了会越做越小java concurrency时,你们用的callable还是runnable?
java在图像分析领域,就是一个扶不起的阿斗多线程编程前景如何?
我来说说go的目标对手吧新版的 eclipse 有什么大的改进?
core java里有跟C++ std::async类似的东西吗?嵌入式编程问题
问个double和long double的问题C++多线程和硬件的关系
瓶颈在哪儿?openMP or boost::thread (pthread) for multithreading ?
java笑node的震惊:java 的矩阵操作比 c++ 快?
相关话题的讨论汇总
话题: java话题: c++话题: executors