search

Home  >  Q&A  >  body text

python - 使用goroutine+channel和java多线程+queue队列的方式开发各有什么优缺点?

我感觉很多项目使用java或者c的多线程库+线程安全的queue数据结构基本上可以实现goroutine+channel开发能达到的需求,所以请问一下为什么说golang更适合并发服务端的开发呢?使用goroutine+channel和java多线程+queue队列的方式开发各有什么优缺点?

巴扎黑巴扎黑2787 days ago575

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-18 10:33:33

    http://tleyden.github.io/blog...

    Goroutine has less overhead than thread and is simpler

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:33:33

    Threads need to grab locks, which will waste CPU performance and turn parallelism into serialization. Gorouten uses notifications to send data to a separate thread to make a copy, and then other threads do not need to compete for locks to truly execute in parallel

    reply
    0
  • Cancelreply