I want blocked exucute some method on my MBean if that method execute allredy. I use in my method doOperation
synchronized(this)
{
//some code......
}public class MyMbean extends org.jboss.system.ServiceMBeanSupport {
String name = "simple";
public void start() throws java.lang.Exception {
}
public String getName(){
return name;
}
public void stop() {
}
public void doOperation(String name,long time){
System.out.println("start operation " + name);
synchronized(this){
try{
Thread.currentThread().sleep(time);
}
catch(Exception e){
e.printStackTrace();
}
this.name = name;
System.out.println("stop operation " + name);
}
}
}