Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

threads in static method  RSS feed

 
Arun Prasath
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Lazy {
private static boolean initialized = false;
static {
Thread t = new Thread(new Runnable() {
public void run() {
initialized = true;
}
});

t.start();
try {
t.join();
} catch(InterruptedException e) {
throw new AssertionError(e);
}
}

public static void main(String[] args) {
System.out.println(initialized);
}
}

the program execution does not get end...
tell me the reason.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this on a sun forum:
http://forum.java.sun.com/thread.jspa?threadID=744969&messageID=4266208




Yours,
Bu.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!