multithreading - Java - creating threads in a EventListener -
multithreading - Java - creating threads in a EventListener -
i got code:
thread thread = new thread(new runnable() { @override public void run() { octopuswsclient.sendpoolsensorreading(poolsensorreading, octopusclientstart.currentmacaddress); } }); thread.setname("thread - ws"); thread.start();
is within event listener executing approximately every 30 seconds (when event occurs), creating new thread every 30 seconds lastly 20 seconds complete, now, question is... ok phone call threads way?, if not, how???... , also, i'm watching threads id , names code:
set<thread> threadset = thread.getallstacktraces().keyset(); for(thread t : threadset){ system.out.println(" thread #"+t.getid()+" name: "+t.getname()); }
and prints id , name current threads, see same number of threads, id incrementing 1 (thread - ws).
is bad signal? fill jvm memory in time?
thanks
you find improve notify single thread resume, rather create multiple ones. if takes 20 seconds complete, @ end lock , create wait till gets command restart loop event listener.
java multithreading jvm runtime
Comments
Post a Comment