title: Slightly confused on threading with Java
body: <p>I'm currently working with <code>Netty.io</code> to create an experimental project in which I nest multiple server instances(different listening ports) into a single application. However Netty pretty much takes over the thread that the <code>ChannelFuture</code> is bound to. <code>Blocks the thread</code> if you will. </p>
  
  <p>Because of this, I've decided that I'm going to need to create a TPS setup, similar to that of a TPC(Thread per client), the application will use a thread for each server instance. </p>
  
  <p>However there's a problem. The only time I've ever created a thread was when I needed to execute a runnable method; However now I'm trying to bind an entire instance of a class to the thread and I'm quite confused on how to go about it.</p>
  
  <p>The only way that I know (Even after about two hours of research) to simulate this would be the following, but it just doesn't feel right.</p>
  
  <pre><code>public class Foo {
  
      public FooBar fooBar;
      private Foo() {
          System.out.println("Foo Thread: " + Thread.currentThread().getId());
          new Thread(new Bar(this)).start();
      }
  
      public static void main(String[] args) {
          new Foo();
      }
  }
  
  class Bar implements Runnable {
  
      Foo foo;
      public Bar(Foo foo) {
          this.foo = foo;
      }
  
      @Override
      public void run() {
          foo.fooBar = new FooBar();
      }
  }
  
  class FooBar {
  
      public FooBar() {
          System.out.println("FooBar Thread: " + Thread.currentThread().getId());
      }
  
  }
  </code></pre>
  
  <p>The above code is executable, but is this the proper way to do it? It seems really hackish to me, but I don't have much experience with this. </p>