g****n 发帖数: 18 | 1 Hello everyone,
I am new to Java and have to ask a simple question.
I am writing a program that has two sockets s1 and s2.
s1 listens to a single client and uses a single thread
s2 listens to possible multiple clients and uses a multithread to track number
of connections, by group.activeCount();
It requires both the single thread and multithread run at the same time. And
the multithread's group.activeCount() needs to be passed to the single thread
every time a thread in the multithread starts or | c****e 发帖数: 90 | 2 Try the following code and you'll see why.
For primitive types, java just copy the value
(instead of passing the reference of that object)
when passing parameters.
class t {
private static void modify(int val)
{
val += 1;
System.out.println("Value of integer inside: "+val);
}
public static void main(String []args){
int t = 0;
modify(t);
System.out.println("Value of integer outside: "+t);
}
}
number
thread
is
【在 g****n 的大作中提到】 : Hello everyone, : I am new to Java and have to ask a simple question. : I am writing a program that has two sockets s1 and s2. : s1 listens to a single client and uses a single thread : s2 listens to possible multiple clients and uses a multithread to track number : of connections, by group.activeCount(); : It requires both the single thread and multithread run at the same time. And : the multithread's group.activeCount() needs to be passed to the single thread : every time a thread in the multithread starts or
|
|