title: Why Java Thread distorts printing to console
body: <p>I have a multithreaded application in Java. In the run method of one of the threads, I have a <pre><code>System.out.println("Print something something something")</code></pre> statement. The problem I have is that sometimes, the output I get from this print is not <code>"Print something something something"</code> but <code>"something Print something something"</code> and some other variations. Please what is the cause of this? The method I am calling in my run method is shown below.</p>
  
  <pre><code>public synchronized void generateRequests() {
  
          String name;
          int qty;
          int index = 0;
          System.out.print("Customer " + custId + " requests, ");
          for (Item i : items) {
              name = i.getName();
              qty = randNoGenerator(0, 10);
              items.set(index, new Item(name, qty));
              index++;
              System.out.print(qty + " " + name + ", ");
          }
  
          s.serviceRequests(this);
      }</code></pre>