(1): Restarting a java program starts a process
You can start runtime. getruntime (). exec ("Java-classpath. xxx") with the operating system command line;
(2): can you add a special processing function to the addtolist function in the module that receives the message? When the function is executed, first add the message to the list, then detect whether there is a processing thread at present, and if not, start the thread.
(3): If you want to save some work, you can use BlockingQueue instead of list, so that thread waiting and waking up can be realized without writing code. If you have to use list, then do a good job of synchronizing
list:
Java codeclass message consumer extends the ad {private list <: YourMessageType> list; private boolean running = true; public MessageConsumer(List< YourMessageType> list) {this.list = list; } public void run() { while (running) { YourMessageType msg = null; try { synchronized(list) { while (list.size() == ) { list.wait(); } msg = list.remove(); list.notiryAll(); } } catch (Exception e) { e.printStackTrace(); } if (msg == null) continue; //System.out.println(msg); //printmessage}}//Call the sample classshare module {list <; YourMessageType> list = new ArrayList< YourMessageType> (); ...}public class Main { public static void main(String[] args) { ShareMudule sm; //so on ... Thread t = new MessageConsumer(sm.list); t.start(); ... }}