x****d 发帖数: 1766 | 1 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? | g*****g 发帖数: 34805 | 2 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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?
| x****d 发帖数: 1766 | 3 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? | g*****g 发帖数: 34805 | 4 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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?
| x****d 发帖数: 1766 | 5 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 发帖数: 34805 | 6 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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.
| p*****2 发帖数: 21240 | | p*****2 发帖数: 21240 | 8
I
It does make your life easier. You can use less resources but do much more
work.
【在 x****d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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.
| x****d 发帖数: 1766 | 9 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : : I : It does make your life easier. You can use less resources but do much more : work.
| g*****g 发帖数: 34805 | 10 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 发帖数: 21240 | 11
months,
justify
这话说的
【在 x****d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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.
| h****r 发帖数: 2056 | 12 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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.
| s*w 发帖数: 729 | 13 did not understand yesterday
do now
ready,
【在 g*****g 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 发帖数: 1766 | 14 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... |
|