Question: How do I implement temporary threads in java, such that they invoke a function in a separate thread(communicate/send packet to another thread) and then terminate while the other threads keep running?

Answer: 
Try This one

```
Thread t = new Thread(){
    public void run(){
       //Thread Implmentation code here
    }

}

t.start();

```
The api for creating a thread is using the class Thread. you can override the `run` method or you can pass a Object that implements the `Runnable` interface and pass to a thread when creating it. `Thread.start` schedules the thread for execution.

Threads in the same JVM can communicate via shared objects; i.e. **you pass a Object to a thread and you can use it as a shared state**. You call the shared object methods to change the state seen by the various threads. When multiple threads communicate each other with one or more shared object you need to assure that the modifications to the object are made in a thread-safe way since the invocations on the shared object can happen concurrently. 

The basic api for regulating access to the shared objects are the use of the `synchronized` keyword and the `wait` and `notify` and `notifyAll` methods methods of the Object class.

[Here is the Oracle tutorial](http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html) on Java concurrency; whe you can find detailed information. over the years Java has evolved in order to make concurrency and synchronization easier to use; there are a lot of classes in the JDK to deal with concurrent operations.