Basic thread question# Java - 爪哇娇娃
w*i
1 楼
In the Java class below, an instance of this class is created on each of 3 threads. I need some help to find any likely serious problem these threads will have with using the Calc mehtod. And what is a good solution?
public class doSomething {
private static int w = 1;
private int x = 1;
private static int y = 100;
private int z = 100;
public int Calc() {
int total = 0;
total = (w * y) + (x * z);
w = w + 1;
x = x + 1;
return (tot
public class doSomething {
private static int w = 1;
private int x = 1;
private static int y = 100;
private int z = 100;
public int Calc() {
int total = 0;
total = (w * y) + (x * z);
w = w + 1;
x = x + 1;
return (tot