Hi!I'm experiencing some problems with threads and can't seem to find a way around.I need some advice so without further ado:i have three classes:one that extendes InputStream and implements Runnable interface with the main task to read from an input stream and write data to a file{let's call it StreamObject}.Second class also implements Runnable and it's main task is to create objects of first class ,and at some point in time stop it{let's call it ShoutStream}.Third class is a swing JFrame with 2 buttons.If i push one button it must create an object with the second class type ,the other button just to unref the object created with first button.Everything work according to plan ,the only problem is that if i create an object of type ShoutStream which create an object of type StreamObject and then destroy the ShoutStream with second button and create another instance of ShoutStream object ,the StreamObject instance created by the first ShoutStream object is still alive .Here's some code to explain my self better:

Java Code:
public class StreamObject extends InputStream implements Runnable{
	Thread t;
	volatile boolean stop =false;
	public StreamObject(String name) {
		super();
		if(t == null)
			t = new Thread(this,name);
	}
	/**
	 * set the input stream to be used for subsequent reads
	 * @param in the InputStream
	 */
	public void setInputStream (InputStream in) {
		this.in = in;
		numbytes = 0;
		offset = 0;
		remainingContent = (in==null)? 0 : Integer.MAX_VALUE;
	}
@Override
	public  void run() {
		
		if(isIcy()){
			DataOutputStream out = null;
			Resources res = Resources.getInstance();
			try {
				out = new DataOutputStream(new FileOutputStream(res.getTmpDir() +"/" + res.getTmpMP3()));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			byte[] toRead = new byte[metaint];
			byte[] oneByte= new byte[1];
			int size;
			try{
				while(!stop){
					byte[] title = null;
					for(int i = 0;i<metaint;i++){
						toRead[i] = (byte) read();
					}
					out.write(toRead);
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			try {
				out.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
	}
	public void stop(){
		System.out.println("<StreamObject><stop><"+ t.getName() + ">" +"Calling stop");
		stop = true;
	}
	public void start(){
		t.start();
	}
Second Class
Java Code:
public class ShoutStream implements Runnable {
	Thread t;
	private volatile boolean stop = false;
	ShoutStream(String[] args,String name){
		this.args = args;
		mainVolume = 0.9;
		if (t == null)
			t = new Thread(this,name);

	}
	public synchronized void start(){
		t.start();
	}
@Override
	public void run() {
		while(!stop){
			
			Gst.main();
			System.out.println("<ShoutStream><run><"+ t.getName() + ">"+"After main gst!");
			//try to close in stream
			try {
///Type in is StreamObject
				in.stop();
				in.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public void stop(){
		stop = true;
	}
	public synchronized void close(){
		System.out.println("<ShoutStream><close><"+ t.getName() + ">"+"Calling close!");
		pipe.setState(State.NULL);
		Gst.quit();
	}
And some piece of code that try to create /delete and create again ShoutStream object

Java Code:
public void actionPerformed(ActionEvent arg0) {
		JButton source = (JButton)arg0.getSource();
		if(source == jbPlay){
			if(shoutStream != null){
				shoutStream.stop();
				shoutStream.close();
			}
			//shoutStream = null;
			shoutStream =  new ShoutStream(args,name);
			shoutStream.start();
		}
		else if(source == jbNext){
			
			if(shoutStream != null){
				shoutStream.stop();
				shoutStream.close();
			}
			shoutStream =  new ShoutStream(args,name);
			shoutStream.setShoutStream(url);
			shoutStream.start();

		}
I just want to understand why StreamObject doesn't end his job.If my code is not clean enough,or maybe i didn't explain myself better please tell me and i will come with more info!Thank you!