挂起并序列化正在运行的线程

编程入门 行业动态 更新时间:2024-10-27 08:39:44
本文介绍了挂起并序列化正在运行的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人知道一种可以捕获正在运行的线程的状态并将其序列化以便进一步恢复的机制吗? JVM有什么可用的吗? pthreads怎么样? 我的主要目标是能够将正在运行的线程迁移到远程计算机.

Does anybody know a mechanism that can capture the state of a running thread and serialize that for further resume? Is there anything available for the JVM? How about pthreads? My main goal is to be able to migrate a running thread to a remote machine.

推荐答案

在该线程的配合下,您可以通过线程支持的任何机制来完成此任务.没有该线程的配合,这是不可能的.如果该线程持有您的序列化代码所需的锁,会发生什么?

With the cooperation of that thread, you can do it by any mechanism that thread supports. Without the cooperation of that thread, it is impossible. What happens if that thread holds a lock that your serialize code needs?

如果迁移当前正在使用某些内核资源(例如管道)的正在运行的线程,会发生什么情况.您将迁移该资源吗?

What happens if you migrate a running thread that is currently using some kernel resource such as a pipe. Will you migrate that resource?

解决您问题的正确方法可能是让线程支持迁移机制.您如何执行此操作完全取决于该线程正在执行的操作.如果您确切地解释了什么,您将获得更有可能帮助您解决实际问题的答案.

The right solution to your problem may be to have the thread support a migration mechanism. How you do that depends on precisely what that thread is doing. You'll get answers that are more likely to help you solve your actual problem if you explain precisely what is.

更多推荐

挂起并序列化正在运行的线程

本文发布于:2023-11-09 20:14:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   挂起   正在运行   序列化

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!