DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=38986>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38986 [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WONTFIX | ------- Additional Comments From [EMAIL PROTECTED] 2006-03-16 15:04 ------- Object synchronization locks object access to any of its methods in respect any other thread that is trying to access this object. Please go over CubbyHole example from sun (http://java.sun.com/docs/books/tutorial/essential/threads/synchronization.html) or just copy and paste following demo into eclipse. /////////////////////////////////////////////////////////////// import java.util.HashMap; import java.util.Map; import java.util.Set; public class SynchronizeDemo { public static Map actions = new HashMap(); public static void main(String[] args) { SynchronizeDemo demo = new SynchronizeDemo(); demo.test(); } public void test(){ MapReader reader = new MapReader(); reader.start(); MapWriter writer = new MapWriter(); writer.start(); } public class MapReader extends Thread{ public void run(){ for(int i = 0; i<250; i++){// read Map 250 times Set keys = actions.keySet(); System.out.print("\n" + this.getClass().getName ()); for(int ii = 0; ii < keys.size(); ii++){// display all actions from the map System.out.print(" ['_action_key_" + ii + "' mapped to '" + actions.get("_action_key_" + ii)+"']"); } } } } public class MapWriter extends Thread{ public void run(){ synchronized(SynchronizeDemo.actions){ for(int i = 0; i<250; i++){// put new action 250 times actions.put("_action_key_" + i, "_action_class_" + i); System.out.println(this.getClass ().getName() + "'_action_key_" + i + "' '_action_class_" + i + "'"); } } } } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]