File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads:Pls. Help

 
rashu gulati
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is true abt the code below::
public class joining{
static Thread createThread(final int i,final thread t1)
{
Thread t2=new Thread(){
public void run(){
System.out.println(i+1);
try{
t1.join();
}catch(Interrupted Exception e){
}
System.out.println(i+2);
}
};
System.out.println(i+3);
t2.start();
System.out.println(i+4);
return t2;
}
public static void main(String[] args)
{
createThread(10,createthread(20,Thread.currentThread()));
}
}
Can anyone explain the sequence to me?
Thanks
Rashu Gulati
 
Vad Fogel
Ranch Hand
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this question was discussed in depth here.
 
Don Wood
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Goodness gracious, what test did this question come from? I suppose that given enough time and caffeine I could answer this one using only pencil and paper but it would be difficult to answer it and 60 other questions in two hours.
Is the complexity of this question representative of the questions on the exam?
[ January 09, 2004: Message edited by: Don Wood ]
 
Vad Fogel
Ranch Hand
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Don Wood:
Goodness gracious, what test did this question come from? I suppose that given enough time and caffeine I could answer this one using only pencil and paper but it would be difficult to answer it and 60 other questions in two hours.
Is the complexity of this question representative of the questions on the exam?
[ January 09, 2004: Message edited by: Don Wood ]

A tricky part of the nested method calls and semantics like this is less likely to be there. Otherwise, the real questions on threads and GC are rather difficult and require practice to approach. Luckily, there are only about 10 of them that come on threads. I'd say, the thread and GC questions were the most challenging, so they are worth revisiting a few times.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic