MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    如何用java异步只阻塞当前事件处理器

    开发交流
    1
    1
    187
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LingerJAB
      LingerJAB last edited by

      (kotlin,java多线程小白💦💦可能很多术语不太会说很抱歉

      需求:异步发送两个http请求,阻塞获取两个值返回进行处理

      我写了一个CompletableFuture future
      问题:我在event监听器处理的时候调用future.join()和future.get()并不能阻塞event处理,导致get没有返回造成NullPointException,

      我想知道join会不会阻塞subcribleAlways(...)和单个event处理线程

      这个在kotlin里面叫做协程吧,类似这样的需求在java里面怎么实现

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact