Z
zebulon
Hi,
how can I perform synchronization in a static class (only static methods and
static fields) since I cannot use the wait()/notify() method ?
What I want to do :
public class X
{
private static data // a list
public static {synchonized? }method1_read_data( .. ) // this method does
not modify the internal state of the data. Must be accessible simultaneously
by differents threads.
// However, if
method2 or method3 is being called it must wait.
public static {synchonized } method2_modify_data(..) // If method2 or
method3 is being called, it must wait.
public static {synchonized } method3_modify_data(..) // If method2 or
method3 is being called, it must wait.
}
If method2 or method3 are declared synchonized , it guarantees that only
one can be called at a time ? right ?
But if I declare also method1 synchonized, it won't be accessible by
differents threads simultaneously , will it be ?
Are there issues concerning performances of static methods'synchronization
?
Thanks for help,
OG
how can I perform synchronization in a static class (only static methods and
static fields) since I cannot use the wait()/notify() method ?
What I want to do :
public class X
{
private static data // a list
public static {synchonized? }method1_read_data( .. ) // this method does
not modify the internal state of the data. Must be accessible simultaneously
by differents threads.
// However, if
method2 or method3 is being called it must wait.
public static {synchonized } method2_modify_data(..) // If method2 or
method3 is being called, it must wait.
public static {synchonized } method3_modify_data(..) // If method2 or
method3 is being called, it must wait.
}
If method2 or method3 are declared synchonized , it guarantees that only
one can be called at a time ? right ?
But if I declare also method1 synchonized, it won't be accessible by
differents threads simultaneously , will it be ?
Are there issues concerning performances of static methods'synchronization
?
Thanks for help,
OG