Results 1 to 3 of 3
Thread: Make a thread Serializable
- 01-17-2011, 10:49 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
Make a thread Serializable
This issue is getting too old, please help me.
I have developed a simple game in java. Everything is fine, the only problem is that when I load a previously save state of the game, It does not load properly. This is due to the Thread class is not serializable.
Is there any way to save the state of a thread to hard disk? or any workaround?
Please help
- 01-17-2011, 11:02 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
You cannot "restart" a Thread anyway so serialising it would do you no good. You need to create some "state" object and make that serialisable, then, when reloading, start a thread using this restored state (and you, of course, will have to create the code for determining what to "store" there, and how to interpret it when reloading it).
- 01-18-2011, 04:37 AM #3
masijade is correct -you can store arrays of item positions, scores, etc... Load that data back in and start a new thread to pick up where the old on left off. You don't just serialize the execution state, you serialize the state of the memory. The execution state should find a stopping point before writing the save, and have the ability to start up from the same arbitrary point. You might need to change your design somewhat to accommodate this.
Similar Threads
-
Drawing Serializable, how to save/load?
By warchieflll in forum New To JavaReplies: 1Last Post: 01-03-2011, 04:06 PM -
Serializable problem
By javaPower in forum Advanced JavaReplies: 3Last Post: 11-30-2010, 10:54 AM -
marking a field Serializable
By user1234 in forum Advanced JavaReplies: 9Last Post: 05-18-2010, 11:27 AM -
Casting to an List<Serializable>
By Whatty in forum Advanced JavaReplies: 5Last Post: 10-15-2009, 07:47 PM -
Implementing Serializable interface
By javaplus in forum Advanced JavaReplies: 4Last Post: 12-18-2007, 12:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks