• 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

dont now how to use threads

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey ppl i need some help...this might be easy 4 u gurus but i dont usually use java....B(

here is my prob, i need to do somefing like this( C ) but in java:

......
if(fork()==0){
//child process code
}else{
//father code
}
....
i visited some pages of sun explaining how to use threads but i didnt understand the usage very well...

this might look like a "u do it 4 me" situation but....how to assign a new thred to somefing...
Thread a= new Thread(this, "Clock");
by example this method

private static int randomName(String wtf){
.....
}

thanks 2 everybody dat triyes 2 help
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no equivalent to fork() in Java. The best you can do is start a thread to handle child code.



With fork(), the child process is actually a separate process, so resource conflicts are not a problem. Furthermore, with fork(), both the parent and child will execute the code after the if-then-else block. Again, there is no equivalent to this in Java.

Henry
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic