?
Sieht's so etwas besser aus?
Ich sehe aus dem folgenden Code nur, dass, die Threads unterschiedlich gestartet werden (zeitlich), aber sehe nicht ob System.out, oder printStacktrace
synchronized sind.
Ist wirklich ein math. Beweis notwendig?
Also ich habe bisher keinen Programmierer gesehen der Methoden mathematisch beweist mit Stift und Zettel.
public class Printstacktrace extends Thread{
static Printstacktrace p1 = new Printstacktrace();
static Printstacktrace p2 = new Printstacktrace();
int function(int a,int b,String str)
{
int c=0;
try
{
c=a/b;
}
catch(Exception ex)
{
ex.printStackTrace();
}
System.out.println(str);
return c;
}
public void run()
{
p1.function(20, 10,"Thread1");
p1.function(23, 0,"Thread1");
p2.function(30, 20,"Thread2");
p2.function(40, 0,"Thread2");
}
public static void main(String[] args)
{
p1.start();
p2.start();
}
}