public class Principal {
private static int x = 0;
private static int y = 0;
public static void sum() {
x = y + 1;
y = x + 1;
}
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
Thread a = new Thread() {
public void run() {
sum();
}
};
a.start();
Thread b = new Thread() {
public void run() {
sum();
}
};
b.start();
System.out.println(x);
}
}
}
How can I write this algorithm using node and javascript? I just do not have the slightest idea how to do it! I was analyzing some forms and found Web Worker
but could not do anything.
What should I do? I do not know how to work with threads on node, I tried to use this example node-threads-to-gogo but it seems that it does not run on windows.