Redian新闻
>
Kotlin 的 coroutine 不是由新建一个 thread 实现的吗?
avatar
Kotlin 的 coroutine 不是由新建一个 thread 实现的吗?# Programming - 葵花宝典
j*2
1
http://www.comm.ohio-state.edu/people/faculty/userprofile/161.h
本科是中国青年政治学院的 传媒专业
博士 Communication & Cognitive Science
现在的Grants:
PI, NSF, “Quantum Decision Theory” (SES 1153846), $50,000 in total, 2012-
2014
PI, the OSU site, Air Force Office of Scientific Research (AFOSR), “
Applications of Quantum Probability Theory to Dynamic Decision Making” (
FA9550-12-1-0397), $607,712 in total, 2012-2015
PI, NSF, “Quantum Information Processing” (SES 0818277), $450,000 in total
, 2009-2012
avatar
m*8
2
定的是里程票,入关时向海关表明几号离开美国,是不是把定里程票的确认邮件打印出
来给他们看就可以了? 谢谢!
avatar
h*i
3
如果面试中有以下这些行为,基本判定为负分公司,千万不要去,或者直接走人。因为
一个良好的公司对待人才的态度必须是有足够的尊重,包括尊重你的简历、尊重你的时
间、尊重你的感受、尊重你的隐私。面试官的一举一动都代表着公司的形象,可以从中
看出一个公司的水平。
面试是相互选择的过程,公司可以不要你,你也可以看不上这公司。
1)「双规」公司
不和你商量什么时候方便,直接要你在规定的时间去规定的地方面试。这种公司几乎是
简历都不会看,把所有投了简历的人集中安排在某一个时间段来面试,进行海选。你准
时到了之后发现还要排队,被刷下来的直接走人,筛选下来的再安排下一轮面试,和一
同面试的还有各种来历不明的应届毕业生。
只要不和你商量面试时间的(至少问一句XXX时间你方便吗),都不要去,负分,对待
人才和对待普工一样。
2)晚上打电话约面试的
超过7点以后打电话约面试的,负分,不是加班严重就是HR太不专业。
刚毕业一年的时候,晚上九点的时候接到过中兴HR小伙的电话,问我要不要去非洲利比
里亚做海外销售,还假设在非洲各种悲催结局比如不幸得疟疾问我怕不怕,我说不怕,
他就一直面到我手机没电,然后等我充电了又继续打过来,后来又没有下文了,严重怀
疑被刚毕业的HR拿来练手了。
正常情况下都是白天打电话,或者贴心一点的HR会在5点-6点之间打过来,因为知道你
快下班了,比较方便接电话。
3)自己找上门的,却说是你投了简历的
这种HR根本就没有用心,没有把你单独对待,她也分不清哪些是主动投的哪些是她自己
找的了,你的简历只不过是她众多简历中的一份,如此不专业的HR,公司也好不到哪里
去,负分。
4)群面
群面本来就是耍猴戏,在校园招聘中采用还可以理解,毕竟要从猴群中选出少数会玩的
猴子采用群面还是一种简单高效的方法。
但社会招聘还用群面就难以理解了,毕竟面试者都是有工作经验的人了,没有什么理由
不能先根据工作背景来详细筛选简历,合则约见,然后一对一详聊,双方付出相同的时
间,公平公正。
但群面的话,用人单位想只花一次的时间同时就面试多个人,根本不可能对每个面试者
有深入了解,叫一群人来面试只录取一个,大部分人都只是充当了炮灰的角色,对于炮
灰来说,付出了时间却只是陪太子读书,完全不公平。
群面过程中,几个人坐一起回答同一个问题,这是没有人权的方法,后来回答的人听到
前面人的答案了,不公平。
部分国内企业和亚洲国家的公司喜欢这么玩,欧美外企一般都是一对一面试。从这一点
也可以看出一个公司对人才的态度。
5)面试时要求带学历证书
几年前面试一公司,HR电话里强调面试的时候要带上学历证书原件,一听就不怎么对劲
,因为从来没遇到过哪个公司要求面试就带学历证书的。面试时HR看了学历证书后她还
要问我要身份证,我心想不会是进了传销组织吧,负分。
6)等待超过半个小时
约好下午2点面试,2点半还不开始面试的,没有时间观念,负分,果断走人。
7)面试登记表要填家庭信息
一些恶心的公司要求细到填父母的职业、工作单位、住址、联系电话的,负分。
avatar
i*p
4
怎么有的文章说没创建新的thread.
avatar
r*n
5
还是有相关的吧 算是communication里面的吧?
avatar
s*p
6
我打印了行程给他们
avatar
i*p
7
怎么做到的?
A function marked with this keyword can suspend a coroutine execution, but
is not blocking the thread.
https://www.kotlindevelopment.com/deep-dive-coroutines/

【在 i**p 的大作中提到】
: 怎么有的文章说没创建新的thread.
avatar
i*b
8
本科学新闻,PhD学的是新闻和认知科学的双专业,而这个Grant是跟认知科学相关的,
不是很夸张啊。楼主是不是以为人家研究物理去了?
avatar
m*8
9
谢谢回复.

【在 s*******p 的大作中提到】
: 我打印了行程给他们
avatar
L*s
10
创建新的thread还叫什么coroutine啊, 创建新的thread实现"coroutine"不是脱裤子放
屁?

【在 i**p 的大作中提到】
: 怎么有的文章说没创建新的thread.
avatar
n*t
11
因為大家就喜歡這這種名字啊。。lol

【在 L*********s 的大作中提到】
: 创建新的thread还叫什么coroutine啊, 创建新的thread实现"coroutine"不是脱裤子放
: 屁?

avatar
i*p
12
知道就说说怎么实现的,不知道就潜着。
插科打诨请到菌斑。

【在 L*********s 的大作中提到】
: 创建新的thread还叫什么coroutine啊, 创建新的thread实现"coroutine"不是脱裤子放
: 屁?

avatar
h*i
13
CSP (communicating sequential processes)
Put plainly, like guvest said, these are all games of goto. "CSP", "
coroutine", "suspend", "park", "yield", "await" etc, whatever word they use,
it means the similar things: save the context, pass the PC elsewhere,
switch back when ready. The detailed differences are academic only.
These are often implemented in the language, not in OS, so it can be "
lightweight", so could be faster. But it may not always be so, because you
can implement CSP with OS threads.
e.g. in Clojure, CSP is implemented as a library via macro (these macros
compile the async code into state machines, eventually to a jump table,
hence a game of goto), backed up by a thread pool. In Clojurescript, CSP is
implemented the same, but Javascript does not have threads, so you basically
have one thread to play the same game.
In non-lisp languages, the same game is played, but it is not implemented as
a library, but in the language itself.
Javascript's async-await, kotlin coroutine, go Goroutine, etc, they are all
similar.
Anyone tells you that theirs is better are either idiots or language zealots
. Ignore them.

【在 i**p 的大作中提到】
: 怎么做到的?
: A function marked with this keyword can suspend a coroutine execution, but
: is not blocking the thread.
: https://www.kotlindevelopment.com/deep-dive-coroutines/

avatar
h*i
14
Did a bit reading, kotlin's coroutines and go's goroutines are also backed
by OS threads in the end.
So basically, they added a scheduler/dispatcher to allocate g/coroutine to
threads. And these threads are from a thread pool with a fixed size (
configurable on system startup)
Not different from how Clojure does it.
avatar
h*i
15
Contrary to most places' warnings, my suggestion to you is to use thousands
of threads for your CSP thread pool. They recommend you to use the same
number of threads as your CPU cores, don't listen to these fools.
Because modern programming is mostly doing IO, you will be blocked on IO
everywhere. If your thread pool is not large enough, you will run out of
threads with heavy load.
Modern Linux machines handles thousands of threads just fine. Compared with
IO, threading context switch costs almost nothing at all.

【在 h*i 的大作中提到】
: Did a bit reading, kotlin's coroutines and go's goroutines are also backed
: by OS threads in the end.
: So basically, they added a scheduler/dispatcher to allocate g/coroutine to
: threads. And these threads are from a thread pool with a fixed size (
: configurable on system startup)
: Not different from how Clojure does it.

avatar
h*i
16
thread pool
the threads are already created. they are reused.

【在 i**p 的大作中提到】
: 怎么有的文章说没创建新的thread.
avatar
i*p
18
确实还是在用thread支持coroutine的运行,有创建新thread的选项。
Coroutine context includes a coroutine dispatcher (see CoroutineDispatcher)
that determines what thread or threads the corresponding coroutine uses for
its execution. Coroutine dispatcher can confine coroutine execution to a
specific thread, dispatch it to a thread pool, or let it run unconfined.
https://kotlinlang.org/docs/reference/coroutines/coroutine-context-and-
dispatchers.html

【在 h*i 的大作中提到】
: thread pool
: the threads are already created. they are reused.

avatar
i*p
19
费解的是这个例子,println运行在 main, 同一个 thread
launch { // context of the parent, main runBlocking coroutine
println("main runBlocking : I'm working in thread ${Thread.
currentThread().name}")
}
main runBlocking : I'm working in thread main

【在 h*i 的大作中提到】
: thread pool
: the threads are already created. they are reused.

avatar
h*i
20
it's entirely possible that they use one thread.
CSP has nothing to do with threads. It's about a game of goto. Turn your
code into a bunch of goto, each with the right context. That's it.
Remember, in Javascript, there's only one thread, you can still do CSP.

【在 i**p 的大作中提到】
: 费解的是这个例子,println运行在 main, 同一个 thread
: launch { // context of the parent, main runBlocking coroutine
: println("main runBlocking : I'm working in thread ${Thread.
: currentThread().name}")
: }
: main runBlocking : I'm working in thread main

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。