The other day I saw Pecking2 talking about "yibu bian cheng". I am an JEE guy, so dont know much about socket api and I am kind of confused. Can someone kindly explain what the heck is asynchronous and what is non- blocking, are they the same? I remember java NIO2 is non blocking, so is it async?
b*s
5 楼
确实很搞 周杰总是鼻孔超天的吗?
l*y
6 楼
青海比较聪明这点,都是从老百姓那边打着慈善的牌子敛财, 大面积的悲剧应该还没 有吧
g*g
7 楼
Asynchronous is always non-blocking. Non-blocking is not necessarily asynchronous. An example is java nio and nio2, in java nio, you can use a thread to monitor many sockets by polling, and it checks if the data is ready. Asynchronous I/O on the other hand, employs the callback. So instead of checking your channels periodically, they'll notify you when they are ready, so you don't need a monitor thread.
【在 x****d 的大作中提到】 : The other day I saw Pecking2 talking about "yibu bian cheng". I am an JEE : guy, so dont know much about socket api and I am kind of confused. : Can someone kindly explain what the heck is asynchronous and what is non- : blocking, are they the same? : I remember java NIO2 is non blocking, so is it async?
Can you explain poll please? I heard that often, select, poll, what is the difference? Java NIO2 has call back, why it does not qualified as async? When Pecking2 said async programming, what exactly he meant? excluding non blocking?
You assign 100 IO tasks to 100 workers (sockets), you check them one by one nonstop until one of them has data and do something about it, that's called polling. If you register a callback and asks the workers to notify you when it has data (or when completed), that's async IO, obviously in the later case you don't need a manager thread. Interested party can register callback on their own. Both are non-blocking however, compared to 100 threads blocked on 100 IOs. NIO2 has async IO, NIO doesn't, if I didn't make that clear in the last post.
【在 x****d 的大作中提到】 : Can you explain poll please? I heard that often, select, poll, what is the : difference? Java NIO2 has call back, why it does not qualified as async? : When Pecking2 said async programming, what exactly he meant? excluding non : blocking?
Thanks ah... So both Java NIO and NIO2 is non blocking, but only NIO2 is async. How about select? what is it? I know a bit about NIO2, I don't see much fun there. Why other guys said async programming is more fun? From programmer aspect, same thing, why do I care if it is async? I don't see how it makes my life any easier.
A Selector is a Java NIO component which can examine one or more NIO Channels, and determine which channels are ready for e.g. reading or writing . It's just a coin name. Async is not about making programmers' life easier, it's about making performance better.
I
【在 x****d 的大作中提到】 : Thanks ah... So both Java NIO and NIO2 is non blocking, but only NIO2 is : async. : How about select? what is it? : I know a bit about NIO2, I don't see much fun there. Why other guys said : async programming is more fun? From programmer aspect, same thing, why do I : care if it is async? I don't see how it makes my life any easier.
I It does make your life easier. You can use less resources but do much more work.
【在 x****d 的大作中提到】 : Thanks ah... So both Java NIO and NIO2 is non blocking, but only NIO2 is : async. : How about select? what is it? : I know a bit about NIO2, I don't see much fun there. Why other guys said : async programming is more fun? From programmer aspect, same thing, why do I : care if it is async? I don't see how it makes my life any easier.
I against your idea as principle. We should gain productivity by making programmer's life easier, in general. CPU capacity is double every 6 months, we shouldn't spend valuable time to reduce resources usage. Do you know how much it costs to train programmers for something new like NIO2 in a big java shop? And the recruiting expenses is huge too. That is why some guys think we guys in java world move slow. But we have to justify the cost and benefit.
【在 p*****2 的大作中提到】 : : I : It does make your life easier. You can use less resources but do much more : work.
It's only an option, NIO2 doesn't deprecate NIO or blocking IO. You choose the best tool for your job. You can stick to blocking IO if that's sufficient, and I'd say that's about 99% of all cases. But a tool rarely can be more efficient and simpler, that's just the nature of it.
months, justify
【在 x****d 的大作中提到】 : I against your idea as principle. We should gain productivity by making : programmer's life easier, in general. CPU capacity is double every 6 months, : we shouldn't spend valuable time to reduce resources usage. : Do you know how much it costs to train programmers for something new like : NIO2 in a big java shop? And the recruiting expenses is huge too. That is : why some guys think we guys in java world move slow. But we have to justify : the cost and benefit.
r*f
26 楼
可能,据说现在香港发展
【在 m*********n 的大作中提到】 : 那么说是得罪行业大牛所以被封杀了?
p*2
27 楼
months, justify 这话说的
【在 x****d 的大作中提到】 : I against your idea as principle. We should gain productivity by making : programmer's life easier, in general. CPU capacity is double every 6 months, : we shouldn't spend valuable time to reduce resources usage. : Do you know how much it costs to train programmers for something new like : NIO2 in a big java shop? And the recruiting expenses is huge too. That is : why some guys think we guys in java world move slow. But we have to justify : the cost and benefit.
m*m
28 楼
在这圈里,又不缺俊男美女,还不是拼演技人品后台,关键是他占哪样啊?
【在 m*********n 的大作中提到】 : 那么说是得罪行业大牛所以被封杀了?
h*r
29 楼
one more point, aio or epoll kind is O(1), poll/select kind is O(n), there could be huge performance difference at server end. google "c10k" can get complete list of articles about this topic.
I
【在 x****d 的大作中提到】 : Thanks ah... So both Java NIO and NIO2 is non blocking, but only NIO2 is : async. : How about select? what is it? : I know a bit about NIO2, I don't see much fun there. Why other guys said : async programming is more fun? From programmer aspect, same thing, why do I : care if it is async? I don't see how it makes my life any easier.
【在 g*****g 的大作中提到】 : Asynchronous is always non-blocking. Non-blocking is not necessarily : asynchronous. An example is java nio and nio2, in java nio, you can use a : thread to monitor many sockets by polling, and it checks if the data is : ready. : Asynchronous I/O on the other hand, employs the callback. So instead of : checking your channels periodically, they'll notify you when they are ready, : so you don't need a monitor thread.
learn something new here every now and then. that is what keep me coming back. but I have to admit many ppl here shit talking, that is what I don't like, anyway...