scala调用java api

这篇博客介绍了如何在Scala中利用Java API创建线程池,通过共享无界队列实现线程复用。当所有线程活跃时,额外的任务会被放入队列等待。如果线程在执行中失败,线程池会创建新的线程继续处理后续任务。此外,还提及了监听特定端口进行Socket通信的内容。
摘要由CSDN通过智能技术生成

1.看一个socket实例,直接调用java api即可

介绍java中的使用thread pool达到内部线程重用,在android也有msg的thread pool

Executors.newFixedThreadPool(poolSize)

     * Creates a thread pool that reuses a fixed number of threads
     * operating off a shared unbounded queue.  At any point, at most
     * <tt>nThreads</tt> threads will be active processing tasks.
     * If additional tasks are submitted when all threads are active,
     * they will wait in the queue until a thread is available.
     * If any thread terminates due to a failure during execution
     * prior to shutdown, a new one will take its

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值