normales Methoden-synchronized
public class MyClass
{
...
public synchronized int rechne()
{
// Code hier
}
...
}
entspricht
public class MyClass
{
...
public int rechne()
{
synchronized(this)
{
// Code hier
}
}
...
}
synchronized bei einer statischen Methode
public class MyClass
{
...
public static synchronized int machwas()
{
// Code hier
}
...
}
entspricht
public class MyClass
{
...
public static int machwas()
{
synchronized(MyClass.class)
{
// Code hier
}
}
...
}
5. Februar 2008
Abonnieren
Kommentare zum Post (Atom)
Keine Kommentare:
Kommentar veröffentlichen