File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes why thread run at end even than place at start  in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Distributed Java
Reply Bookmark "why thread run at end even than place at start  in java?" Watch "why thread run at end even than place at start  in java?" New topic
Author

why thread run at end even than place at start in java?

Tahir Mehmood
Greenhorn

Joined: Nov 04, 2011
Posts: 3
public static void main(String[] args){
try{
Threadcheck tc=new Threadcheck();
new Thread(tc).start();
System.out.println("mid");
tc.show();
System.out.println("get threadcheck="+tc.getP());
System.out.println("I at end="+Threadcheck.i);
Threadshow ts=new Threadshow();
ts.show2();
System.out.println("get threadshow="+ts.get());
}catch(Exception ex){

System.out.println(ex);

}





}//main
Thread will run at end although written frist
output
mid
i form show=10
p form show=30
get threadcheck=30
I at end=11
i form show2=11
get threadshow=88888888
step10
step11
step12

Chris Janicki
Greenhorn

Joined: Aug 30, 2006
Posts: 21

1. You didn't provide enough info to definitively respond.

2. Threads are funny things. They are not guaranteed to immediately start just because you call start(). You should search for some tutorials on "concurrency" in java for techniques to schedule/coordinate threads in a deterministic manner.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: why thread run at end even than place at start in java?
 
Similar Threads
JQ+ Question
Which method??
Thread help please!
Thread object creation
Thread ques.