• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Threads:Pls. Help

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, this question was discussed in depth here.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic