java对象序列化 - 线程安全? [英] java object serialization - thread safe?

查看:272
本文介绍了java对象序列化 - 线程安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写高度并发应用程序,这是广泛修改MyClass的对象。类由几个字段组成。我的问题是如何防止特定对象在其序列化期间由另一个线程的修改?

I am writing highly concurrent application, which is extensively modifies objects of MyClass. The class is composed of several fields. My question is how to prevent modifications of particular object during its serialization by another thread?

尊敬的,
Matt

Regards, Matt

推荐答案

href =http://download.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html>同步序列化和修改对象状态的方法。

By synchronizing both the methods which serialize and modify the object state.

这篇关于java对象序列化 - 线程安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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