3
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 don’t have a clue how to do it! I was analyzing some shapes and I found the Web Worker
but I couldn’t do anything.
What should I do? I don’t know how to work Node threads, I tried using this example Node-threads-a-Gogo but it seems that it does not run in windows.
I think this should help to understand and simulate some situations similar to Thread in Javascript http://answall.com/a/100657/3635, understand that Javascript works only with a single thread (although eventually async), look for the written part Example with web Workers
– Guilherme Nascimento
Possible duplicate of How to release frozen/locked thread?
– Guilherme Nascimento
@Guilherme , thanks . I had already read this example ! But the problem is that I still have no code in javascript!!!
– Pena Pintada
I don’t think I understand, you don’t have or know anything about javascript?
– Guilherme Nascimento
Related: http://answall.com/a/45721/3635
– Guilherme Nascimento