Basically I have an integer array which i want to hand over to a thread, but i can’t get the syntax right.
// Create list
List <Integer> list = new ArrayList<Integer>();
// Create thread
TPServer server = new TPServer(port, <Integer> list);
new Thread(server).start();
// Below is the TPServer class
// TPServer Class
public class TPServer implements Runnable {
private List <Integer> list = null;
private int port = 0;
private boolean isStopped = false;
public TPServer(int port, List <Integer> list) {
this.list = list;
this.port = port;
}
}
You haven’t implemented
Runnableand also it should benew TPServer(port, list);