This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Migration

 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to transfer a thread from one mobile device to another using J2ME . This is to continue its execution in case one device is stop running. Could you help me please ?
Thanks
 
Swastik Dey
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by transferring a thread?
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean a thread running on one machine is stopped saved with its current state then migrated to another machine and resume running it from its saved state
 
Henry Wong
author
Marshal
Pie
Posts: 20880
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To migrate a single thread, you will need to migrate the whole program -- along with any opened resources. Keep in mind that a thread can have access to all memory and resources of the JVM. So, the whole JVM will need to be suspended, and then resumed on the other machine (including any opened resources).

Quite frankly, I don't think it can be done. But these days, with virtualization, I would not be surprised if someone releases a product to "VMotion" between anything these days.

Henry

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are thinking about the problem the wrong way.

You can create a Runnable object that is Serializable and transfer that. If you have saved the state of the process correctly, a new Thread can start executing the run() method on the new machine.

Thread objects are intimately tied to the JVM and operating system they are created on - it makes no sense to try to transfer one.

Bill
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I heared it can be done for Java using JavaGo tool but I want to do it for J2ME. Could you guide me how to do it even if I want to submit the whole program.
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear William Could you please explain more .Thanks
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take what William said and do some research. You will need to make anything that needs to go to the other device Serializable. If you don't know what that is, or how to do it then you should read this as well as any Tutorials you can find. What you should do for practice is start your application running, serialize it, close it, start up a new VM, deserialize the old application, and continue running from where you left off. If you properly serialize things (and take care of those situations where serialization is not possible or practicle) then you should be able to do this any number of times.

Then it is just a matter of generating a protocol to move from one location to another. I am not familiar with J2ME so I don't know what the best method will be for that, but if it were me - once I was done with the above steps, I would then research what people are using for communicating binary data between J2ME applications. When I knew this I could use it to transfer the serialized classes from above from one device to another then run it.

As for JavaGo - Don't know what that is, if you have a reference you can point to then that would help - or if it has a tutorial/contact/forum resources that you might be able to use to get more targeted help on that product, then perhaps you should use them.
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is that J2ME doesnot support serialization??
The site for JavaGo is http://homepage.mac.com/t.sekiguchi/javago/
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, no serializing on J2ME will hurt you, but not kill you. You should understand the concepts - and be able to do it successfully in JavaSE. Then, when you know how it works in general you will have to roll your own. This sounds hard - and it probably is. The DataOutputStream and DataInputStream will be your friends. I did a quick google for J2ME Serialization and found a hand full of resources demonstrating how it can be done. But I wouldn't suggest doing it until you understand how Serialization works in general first (for example, try the built in serialization with different versions of JVMs on different machines).

It looks like JavaGo requires JavaSE serialization, so no, you can't use that on J2ME. It also looks like it hasn't been updated since 2005, so I wouldn't suggest using it on modern JVMs with JavaSE either.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic