complicated wait-notify example