首页 \ 问答 \ 不同池中的线程之间的通信java(communication between threads in the different pools java)

不同池中的线程之间的通信java(communication between threads in the different pools java)

我有两个本地线程池,一个池有4个线程,第二个池有5个线程。

我希望这两个池相互通信。

例如,第一个池的第二个线程(1.2)与第二个池的第五个线程(2.5)进行通信,即,

1.2 -> 2.5
1.1 -> 2.2
1.3 -> 2.1
1.4 -> 2.3

1.2完成将消息发送到2.5并且想要将另一个消息发送到第二个池,但2.5仍然很忙,但是如果可以自由地处理来自1.2的消息,则2.4是2.4

如何使第一个池中的线程与第二个池中的第一个空闲线程通信?

我如何在java中实现它?

也许我应该使用消息中间商或类似的东西? (或BlockingQueue,Exchanger / Pipereader

谢谢


I have two local threadpools, one pool has 4 threads, second pool has 5 threads.

I want these two pools communicate with each other.

For example, first pool's second thread (1.2) communicates with the second pool`s fifth thread (2.5), i.e.

1.2 -> 2.5
1.1 -> 2.2
1.3 -> 2.1
1.4 -> 2.3

1.2 finished sending the message to 2.5 and wants to send the other message to the second pool, but 2.5 is still busy, but 2.4 if free to process messages from 1.2

How do I make threads from first pool communicate to the first free thread from second pool?

How can I implement it in java?

Perhaps I should use a message brokers or something like that? (or BlockingQueue,Exchanger/Pipereader)

Thanks


原文:https://stackoverflow.com/questions/41319701
更新时间:2023-06-22 16:06

最满意答案

您可以捕获鼠标事件,记下坐标,然后将这些坐标添加到工具提示相对于页面的实际位置。 然后你可以使用这些坐标重新发射一个假的MouseEvent ,减去底层元素的底层div元素的坐标。


Actually, on browsers that support css3, pointer-events is the simplest solution. :)

相关问答

更多
  • 您可以捕获鼠标事件,记下坐标,然后将这些坐标添加到工具提示相对于页面的实际位置。 然后你可以使用这些坐标重新发射一个假的MouseEvent ,减去底层元素的底层div元素的坐标。 Actually, on browsers that support css3, pointer-events is the simplest solution. :)
  • 在div上设置z-index css属性。 较高的z-index数意味着div将位于具有较低z-index的那些之上。 .map{ z-index: 1; } .contact { z-index: 2; } .content{ z-index: 3; } Set the z-index css properties on the divs. A higher z-index number means the div will be on top of those with low ...
  • 将.hero { z-index: 5} (或任何大于2的数字)设置为可用。 /********************************/ /* Fade Bs-carousel */ /********************************/ .fade-carousel { position: relative; height: 850px; } .fade-carousel .carousel-inner .item { ...
  • 查看我的示例,以便了解工作流程。 演示工作
    • Home
    • about
    • serive
    • contact
    Home worlld ...
  • 你不能用CSS做到这一点但是 您可以尝试使用jQuery,请参阅小提琴: https : //jsfiddle.net/nileshmahaja/4ghws6wz/3/ $(".innerDiv").mouseover(function(){ $(this).parent().siblings().css('opacity', 1); }); $(".innerDiv").mouseout(function(){ $(this).parent().siblings().css('opacity', ...
  • 如果我做得对,你想要div元素显示你是否已经覆盖它并在鼠标未结束时隐藏。 如果就是这样,你只能使用html和css: