挂起并序列化正在运行的线程 [英] Suspending and serializing a running thread

查看:85
本文介绍了挂起并序列化正在运行的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道一种可以捕获正在运行的线程的状态并将其序列化以便进一步恢复的机制吗?
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.

这篇关于挂起并序列化正在运行的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆