Esempio n. 1
0
 public static void main(String[] args) throws InterruptedException {
   MyThread th1 = new MyThread();
   MyThread th2 = new MyThread();
   th1.setName("1");
   th2.setName("2");
   th1.start();
   th2.start();
   th1.join();
   th2.join();
   System.out.println(sb.toString());
 }
Esempio n. 2
0
 public static void main(String[] args) {
   Account account = new Account();
   MyThread thread1 = new MyThread(100, 10, account);
   MyThread thread2 = new MyThread(-100, 10, account);
   thread1.start();
   thread2.start();
   try {
     thread1.join();
     thread2.join();
   } catch (Exception e) {
     e.printStackTrace();
   }
   System.out.println(account.getBalance());
 }
Esempio n. 3
0
 public static void main(String a[]) throws Exception {
   t.start();
   for (int i = 0; i < 10; i++) {
     t.join();
     System.out.println(message + i);
   }
 }
Esempio n. 4
0
 public static void main(String[] args) throws InterruptedException {
   MyThread thread1 = new MyThread();
   MyThread thread2 = new MyThread();
   thread1.start();
   thread2.start();
   thread1.join();
   thread2.join();
   System.out.println(Counter.getCounter());
   System.out.println("Hellow to you too!");
   MyRunnable runnable = new MyRunnable(4, 2);
   Thread thread3 = new Thread(runnable);
   thread3.start();
   System.out.println("LOL I'm Not I'm a MAIN Thread!");
   ThreadVisibility thread4 = new ThreadVisibility();
   thread4.start();
   Thread.sleep(1000);
   thread4.setToFalse();
   System.out.println("keepRunning is false");
 }
Esempio n. 5
0
    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
      boolean retry = true;
      vThread.setRunning(false);
      while (retry) {
        try {
          vThread.join();
          retry = false;
        } catch (InterruptedException e) {

        }
      }
    }
Esempio n. 6
0
  public static void StartUnloadingAppend(int SessNo)
      throws IOException, InterruptedException, SQLException {
    System.out.println(
        (new StringBuilder("Unloading Files for Session - "))
            .append(SessNo)
            .append(" is Started")
            .toString());
    for (int i = 0; i < totalvalues; i++) {
      int val = i + 1;
      writer =
          new FileWriterWithEncoding(
              new File((String) filename.get(i)),
              Charset.forName((String) characterset.get(i)),
              true);
      mt =
          new MyThread(
              (new StringBuilder("Unload")).append(SessNo).append(val).toString(),
              writer,
              (ResultSet) rs.get(i),
              val,
              (String) fetchsize.get(i),
              (String) rowsep.get(i),
              (String) delim.get(i),
              (String) header.get(i),
              (String) filename.get(i));
      mt.setName((new StringBuilder("Unload")).append(SessNo).append(val).toString());
      mt.start();
      mt.join();
    }

    System.out.println(
        (new StringBuilder("Unloading Files for Session - "))
            .append(SessNo)
            .append(" is Completed")
            .toString());
    System.out.println("Process Completed");
    stmt.close();
    filename = new ArrayList();
    delim = new ArrayList();
    rowsep = new ArrayList();
    characterset = new ArrayList();
    fetchsize = new ArrayList();
    header = new ArrayList();
    rs = new ArrayList();
  }