Click here to Skip to main content
15,888,026 members
Home / Discussions / Java
   

Java

 
AnswerRe: Java Pin
Richard MacCutchan1-Jul-15 0:25
mveRichard MacCutchan1-Jul-15 0:25 
QuestionJquery slideshow Pin
vikkismarty29-Jun-15 4:56
vikkismarty29-Jun-15 4:56 
AnswerRe: Jquery slideshow Pin
Richard MacCutchan29-Jun-15 5:08
mveRichard MacCutchan29-Jun-15 5:08 
Questionjava programming Pin
vikkismarty29-Jun-15 1:15
vikkismarty29-Jun-15 1:15 
AnswerRe: java programming Pin
Richard MacCutchan29-Jun-15 3:38
mveRichard MacCutchan29-Jun-15 3:38 
GeneralRe: java programming Pin
vikkismarty29-Jun-15 4:55
vikkismarty29-Jun-15 4:55 
AnswerRe: java programming Pin
Member 117346789-Jul-15 1:40
Member 117346789-Jul-15 1:40 
Questionjava Pin
Shyam Narayan28-Jun-15 5:36
Shyam Narayan28-Jun-15 5:36 
class NewThread implements Runnable {
  String name;
  Thread t;

  NewThread(String threadname) {
    name = threadname;
    t = new Thread(this, name);
    System.out.println("New thread: " + t);
    t.start();
  }
  public void run() {
    try {
      for (int i = 5; i > 0; i--) {
        System.out.println(name + ": " + i);
        Thread.sleep(1000);
      }
    } catch (InterruptedException e) {
      System.out.println(name + " interrupted.");
    }
    System.out.println(name + " exiting.");
  }
}

public class Main {
  public static void main(String args[]) {
    NewThread ob1 = new NewThread("One");
    NewThread ob2 = new NewThread("Two");
    NewThread ob3 = new NewThread("Three");
    System.out.println("Thread One is alive: " + ob1.t.isAlive());
    System.out.println("Thread Two is alive: " + ob2.t.isAlive());
    System.out.println("Thread Three is alive: " + ob3.t.isAlive());

    try {
      System.out.println("Waiting for threads to finish.");
      ob1.t.join();
      ob2.t.join();
      ob3.t.join();
    } catch (InterruptedException e) {
      System.out.println("Main thread Interrupted");
    }
    System.out.println("Thread One is alive: " + ob1.t.isAlive());
    System.out.println("Thread Two is alive: " + ob2.t.isAlive());
    System.out.println("Thread Three is alive: " + ob3.t.isAlive());
    System.out.println("Main thread exiting.");
  }
}

Joining the default main thread with a background thread


public class Main {
  public static void main(String[] args) {
    Runnable r = new Runnable() {
      @Override
      public void run() {
        System.out.println("sleeping for 5 seconds.");
        try {
          Thread.sleep(5000);
        } catch (Exception ie) {
        }
        System.out.println("Worker thread is done");
      }
    };
    Thread thd = new Thread(r);
    thd.start();
    System.out.println("main thread is running.");
    try {
      Thread.sleep(2000);
    } catch (InterruptedException ie) {
    }
    System.out.println("main thread is waiting for worker thread.");
    try {
      thd.join();
    } catch (InterruptedException ie) {
    }
  }
}




in these wt is meaning of ob1.t.join()
like statement plz anyone
AnswerRe: java Pin
Richard MacCutchan28-Jun-15 21:30
mveRichard MacCutchan28-Jun-15 21:30 
QuestionJVM process to execute a java program Pin
NCRK Rajput24-Jun-15 4:17
NCRK Rajput24-Jun-15 4:17 
AnswerRe: JVM process to execute a java program Pin
Richard MacCutchan24-Jun-15 22:21
mveRichard MacCutchan24-Jun-15 22:21 
QuestionRefactor Pin
Member 1151769915-Jun-15 13:05
Member 1151769915-Jun-15 13:05 
AnswerRe: Refactor Pin
Richard MacCutchan15-Jun-15 21:47
mveRichard MacCutchan15-Jun-15 21:47 
AnswerRe: Refactor Pin
Member 1177254417-Jun-15 1:28
Member 1177254417-Jun-15 1:28 
AnswerRe: Refactor Pin
Member 117346789-Jul-15 1:42
Member 117346789-Jul-15 1:42 
Questionselenium webdriver Pin
harshad mudda12-Jun-15 20:56
harshad mudda12-Jun-15 20:56 
SuggestionRe: selenium webdriver Pin
Richard MacCutchan12-Jun-15 22:14
mveRichard MacCutchan12-Jun-15 22:14 
QuestionBanking Domain MutliThreading Pin
Member 1175557710-Jun-15 0:36
Member 1175557710-Jun-15 0:36 
AnswerRe: Banking Domain MutliThreading Pin
Sascha Lefèvre10-Jun-15 1:05
professionalSascha Lefèvre10-Jun-15 1:05 
Questionhow to develop the app using java platform like sms alert with voice call play Pin
Vijaya Kumar9-Jun-15 18:30
Vijaya Kumar9-Jun-15 18:30 
AnswerRe: how to develop the app using java platform like sms alert with voice call play Pin
Richard MacCutchan9-Jun-15 21:11
mveRichard MacCutchan9-Jun-15 21:11 
QuestionCan anyone recommend any good java tutorials? Pin
Adamdew933-Jun-15 11:52
Adamdew933-Jun-15 11:52 
AnswerRe: Can anyone recommend any good java tutorials? Pin
Richard MacCutchan3-Jun-15 21:41
mveRichard MacCutchan3-Jun-15 21:41 
GeneralRe: Can anyone recommend any good java tutorials? Pin
amitjfdi5-Jun-15 2:33
amitjfdi5-Jun-15 2:33 
GeneralRe: Can anyone recommend any good java tutorials? Pin
Member 1068598231-Aug-15 8:46
Member 1068598231-Aug-15 8:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.