Hey guys, I'm a little bit out of my depth on this one. The preceding tasks were straightforward enough, but I'm not really sure what this task is asking me. Can anyone lend a hand?
package com.codegym.task.task20.task2015;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
/*
Overriding serialization
*/
public class Solution implements Serializable, Runnable {
private transient Thread runner;
private int speed;
public Solution(int speed) {
this.speed = speed;
runner = new Thread(this);
runner.start();
}
public void run() {
// Do something here, doesn't matter what.
}
/**
Override serialization.
To do this, you need to declare the following methods:
private void writeObject(ObjectOutputStream out) throws IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
Now serialization/deserialization will work for our scenario :)
*/
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(this);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
in.readObject();
Thread th = new Thread(this);
th.start();
}
public static void main(String[] args) {
}
}