g*e
2 楼
public class Test extends Thread{
static String sName = "good";
public static void main(String argv[]) {
Test t = new Test();
t.start();
System.out.println(sName);
}
public void run() {
for (int i = 0; i < 2; i++) {
sName = sName + " " + i;
}
}
}
这个输出难道不是good, good 0, good 0 1的任何一种吗。答案只有good
static String sName = "good";
public static void main(String argv[]) {
Test t = new Test();
t.start();
System.out.println(sName);
}
public void run() {
for (int i = 0; i < 2; i++) {
sName = sName + " " + i;
}
}
}
这个输出难道不是good, good 0, good 0 1的任何一种吗。答案只有good
c*l
3 楼
Electrochemical investigation of contact angle and of flotation in the
presence of alkylxanthates. I. Platinum and gold surfaces
JR Gardner and R Woods
Aust. J. Chem., 27 (1974)2139
presence of alkylxanthates. I. Platinum and gold surfaces
JR Gardner and R Woods
Aust. J. Chem., 27 (1974)2139
j*a
4 楼
i dont get it.
q*u
5 楼
this is interesting, I have run it under win7, mac os 10 and ubuntu 8 within
eclipse, all only 'good' printed out.
public class Test extends Thread{
static String sName = "good";
public static void main(String argv[]) {
Test t = new Test();
t.start();
System.out.println(sName);
}
public void run() {
for (int i = 0; i < 2; i++) {
sName = sName + " " + i;
【在 g**e 的大作中提到】
: public class Test extends Thread{
: static String sName = "good";
: public static void main(String argv[]) {
: Test t = new Test();
: t.start();
: System.out.println(sName);
: }
:
: public void run() {
: for (int i = 0; i < 2; i++) {
eclipse, all only 'good' printed out.
public class Test extends Thread{
static String sName = "good";
public static void main(String argv[]) {
Test t = new Test();
t.start();
System.out.println(sName);
}
public void run() {
for (int i = 0; i < 2; i++) {
sName = sName + " " + i;
【在 g**e 的大作中提到】
: public class Test extends Thread{
: static String sName = "good";
: public static void main(String argv[]) {
: Test t = new Test();
: t.start();
: System.out.println(sName);
: }
:
: public void run() {
: for (int i = 0; i < 2; i++) {
f*m
6 楼
呵呵,你print两遍sName看看什么结果
within
【在 q*********u 的大作中提到】
: this is interesting, I have run it under win7, mac os 10 and ubuntu 8 within
: eclipse, all only 'good' printed out.
:
: public class Test extends Thread{
: static String sName = "good";
: public static void main(String argv[]) {
: Test t = new Test();
: t.start();
: System.out.println(sName);
: }
within
【在 q*********u 的大作中提到】
: this is interesting, I have run it under win7, mac os 10 and ubuntu 8 within
: eclipse, all only 'good' printed out.
:
: public class Test extends Thread{
: static String sName = "good";
: public static void main(String argv[]) {
: Test t = new Test();
: t.start();
: System.out.println(sName);
: }
g*g
8 楼
Doesn't really prove anything, put a sleep before println.
The result will vary.
difference
【在 q*********u 的大作中提到】
: under mac os and ubuntu8, there are:
: good
: good
: and
: good
: good 0 1
: i don't want reboot to win for testing, it's silly.
: with one println, only 'good' is printed, but 2 println shows the difference
The result will vary.
difference
【在 q*********u 的大作中提到】
: under mac os and ubuntu8, there are:
: good
: good
: and
: good
: good 0 1
: i don't want reboot to win for testing, it's silly.
: with one println, only 'good' is printed, but 2 println shows the difference
q*u
9 楼
yes,
but with only one println, the result is not so unpredictable.
should i just consider this is just a un-flexible thread schedule?
Doesn't really prove anything, put a sleep before println.
The result will vary.
difference
【在 g*****g 的大作中提到】
: Doesn't really prove anything, put a sleep before println.
: The result will vary.
:
: difference
but with only one println, the result is not so unpredictable.
should i just consider this is just a un-flexible thread schedule?
Doesn't really prove anything, put a sleep before println.
The result will vary.
difference
【在 g*****g 的大作中提到】
: Doesn't really prove anything, put a sleep before println.
: The result will vary.
:
: difference
s*n
11 楼
what's the possible outputs of the following program
class Test extends Thread
{
static String s = "good";
static int i = 0;
public void run()
{
s = "better";
i++;
}
public static void main(String argv[]) throws Exception
{
Test t = new Test();
t.start();
while(NOTDONE)
Thread.sleep(1000);
System.out.println(s);
}
}
if the NOTDONE expression is actually:
1) i==0
2) s.equals("good")
3) t.isAlive()
class Test extends Thread
{
static String s = "good";
static int i = 0;
public void run()
{
s = "better";
i++;
}
public static void main(String argv[]) throws Exception
{
Test t = new Test();
t.start();
while(NOTDONE)
Thread.sleep(1000);
System.out.println(s);
}
}
if the NOTDONE expression is actually:
1) i==0
2) s.equals("good")
3) t.isAlive()
s*n
14 楼
Anybody? This is not easy. If you can answer all 3 questions correctly, you
are a master of java concurrency, or at least you can play one on internet.
【在 s******n 的大作中提到】
: what's the possible outputs of the following program
: class Test extends Thread
: {
: static String s = "good";
: static int i = 0;
: public void run()
: {
: s = "better";
: i++;
: }
are a master of java concurrency, or at least you can play one on internet.
【在 s******n 的大作中提到】
: what's the possible outputs of the following program
: class Test extends Thread
: {
: static String s = "good";
: static int i = 0;
: public void run()
: {
: s = "better";
: i++;
: }
l*3
17 楼
my understanding is if NOTDONE is true, thread.sleep will put main thread to
pause for at least 1 second, which will give test thread enough time to
complete. if NOTDONE is false, which means test thread is done. so all three
answers r better. could you elaborate your thoughts? thanks.
【在 s******n 的大作中提到】
: no.
pause for at least 1 second, which will give test thread enough time to
complete. if NOTDONE is false, which means test thread is done. so all three
answers r better. could you elaborate your thoughts? thanks.
【在 s******n 的大作中提到】
: no.
相关阅读
求审稿,robotics, mechantronics, vibration and control 方向会议问题求助CAD figuresCFP: Recent Advances in Deformable Image Registration (转载)请问每年教授的funding什么时候出结果哪位朋友愿意做machinery方面的翻译吗? (转载)Full time position in Qualcomm at San DiegoIET国际雷达会议中英文征稿通知bioME Ph.D.方向选择求两篇paper,多谢!!!Job Openings: CSST Research Hong Kong (转载)医生和商学院教授,哪个收入高?求教fortran,在线等!PhD student positions in ME with full financial support ava (转载)有工业设计的高手没有?南京信息工程大学物理与光电工程学院招聘公告zz请教一个问题锂电池的工作机会 (转载)求审稿机会-纤维增强高分子复合材料,纳米复合材料前任老板用我的数据发文章,但是不写我的名字咋办