I want to send the same object for two clients. I use object write unshared method and read unshared. The class of my object is:
package servidor;
import java.io.Serializable;
public class Token implements Serializable {
private static final long serialVersionUID = -5399605122490343339L;
public static String sender, receiver, content;
String id;
public Token(String sender, String receiver, String content){
Token.sender = sender;
Token.receiver = receiver;
Token.content = content;
}
public static Token returnToken(){
Token token = new Token(Token.sender, Token.receiver, Token.content);
return token;
}
public static String returnSender(){
return Token.sender;
}
public boolean hasToken(String id){
if(Token.sender.equals(id)){
return true;
}
else {return false;}
}
}
But, when I use the method returnSender
on the client side, the return is null
. I'm checked and I no have errors in receive the object by readUnshared()
. I have in both sides the class Token include in server package.
I have one thread per client, and the threads seek the same object to send.
How can send the same object for various clients in different threads?