java - Web Server: use Service instead of Thread -
I have written an app that implements a web server with multithreading. The main activity has a button to start / stop a thread. When the server is on, it stays in listening to the thread and, if there is a request, it creates a new thread to serve it. The app works fine, but now I use a service instead, so it can work in the background.
Actually, I have done this design:
Web server Java DroidServer.java MyActivity.java What should I change to use the services? I want to extend the service to DroidServer, but this class has already expanded any solution to the webserver ...? Service is not a replacement for a thread from per definition: The most confusions about the service class revolve in reality which is not: What should you do to make this a service, then run your DroidServer in service to run as a separate thread in order to accept the request in the background
class extends the DroidServer webserver {...} < / Pre>
increases the MyActivity activity of the public class {ws = new DroidServer (8080, this); Btn.setOnClickListener (New OnClickListener) {Click on Public Zero (see V) {if (! Ws.isOn ()) {ws.start (); BT.N.Set Text ("Stop");} and {Yststop ( ); Btn.setText ("Start");}}}); }
Comments
Post a Comment