J
Jack Dowson
Hello Everybody:
I'm new to java.
Here is a demo about java's multithread character:
class MultiThread extends Thread{
private int ticket = 100;
MultiThread(String name){
super(name);
}
public void run(){
while(ticket>0){
System.out.println(ticket-- +" is saled by " +
currentThread().getName());
}
}
}
public class MultiThreadDemo{
public static void main(String[] args){
MultiThread m1 = new MultiThread("Window 1");
MultiThread m2 = new MultiThread("Window 2");
MultiThread m3 = new MultiThread("Window 3");
m1.start();
m2.start();
m3.start();
}
}
When I run this program I had checked the process option card of task
manager at the same time.I found there are 11 threads in the process
java(sometimes maybe 4).
I'm confused.
Who can tell me what those threads indeed are if it's possible to identify.
And another problem:what's the time interval for each timeslice?
Any help will be greatly appreciated!
I'm new to java.
Here is a demo about java's multithread character:
class MultiThread extends Thread{
private int ticket = 100;
MultiThread(String name){
super(name);
}
public void run(){
while(ticket>0){
System.out.println(ticket-- +" is saled by " +
currentThread().getName());
}
}
}
public class MultiThreadDemo{
public static void main(String[] args){
MultiThread m1 = new MultiThread("Window 1");
MultiThread m2 = new MultiThread("Window 2");
MultiThread m3 = new MultiThread("Window 3");
m1.start();
m2.start();
m3.start();
}
}
When I run this program I had checked the process option card of task
manager at the same time.I found there are 11 threads in the process
java(sometimes maybe 4).
I'm confused.
Who can tell me what those threads indeed are if it's possible to identify.
And another problem:what's the time interval for each timeslice?
Any help will be greatly appreciated!