I am pretty new to Android programming but got some experience in other languages. I want to create an APP which is principle working like this.

The APP is a process which is asking my Web-/Database-Server every 10 seconds if there is an event to execute.
The Web-/Database-Server answers with an event id or even a function name.
- The APP opens a new thread which executes the event with the id or even better directly the function name.
My Questions are:
- Is this perfomant? Or can this chrash pretty easily?
- Is it limited to 2 threads within the process or can I even open every time a new thread for the function which I want to execute? Maybe because of the other function is still running?
How can I execute a function with the return value? For example
InputStream in = response.getEntity().getContent(); //Get the data in the entitypublic in(void) { // execute a function which got´s the same name as the variable "in" }
The result should be: The one thread is asking every 10 seconds my Web-/Database-Server if there is an event. The event gets executed within a thread and this is working parallel (at the same time without crashing or even getting stucked).
Sample Code of these Threads would be appreciated.
My code till yet:
public class service extends Service { private static final String TAG = "MyService";
@Override public IBinder onBind(Intent intent) { return null; } public void onDestroy() { Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show(); Log.d(TAG, "onDestroy"); } @Override public int onStartCommand(Intent intent, int flags, int startid) { Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show(); Log.d(TAG, "onStart"); Thread thread = new Thread(new Runnable() { @Override public void run() { new Timer().scheduleAtFixedRate(new TimerTask() { @Override public void run() { System.out.println("Send GO!"); Device dev = new Device(); dev.getDeviceId(getBaseContext()); dev.getEmail(getBaseContext()); dev.sendDeviceItems(); } }, 0, 10000);//put here time 1000 milliseconds=1 second } }); thread.start(); return Service.START_STICKY; } }