155:, the guarded suspension pattern is generally only used when the developer knows that a method call will be suspended for a finite and reasonable period of time. If a method call is suspended for too long, then the overall program will slow down or stop, waiting for the precondition to be satisfied. If the developer knows that the method call suspension will be indefinite or for an unacceptably long period, then the
1078:
22:
138:
to be satisfied before the operation can be executed. The guarded suspension pattern is typically applied to method calls in object-oriented programs, and involves suspending the method call, and the calling thread, until the precondition (acting as a
1119:
445:
179:, if there is no precondition satisfied for the method call to be successful, then the method will wait until it finally enters a valid state.
1143:
39:
970:
1138:
995:
398:
127:
105:
768:
86:
943:
567:
418:
Kuchana, Partha (2004). "Software
Architecture Design Patterns in Java" (Document). Boca Raton, Florida: Auerbach Publications.
58:
751:
661:
43:
791:
761:
756:
1112:
438:
65:
1036:
874:
72:
651:
32:
859:
854:
681:
1105:
899:
864:
831:
481:
431:
356:
140:
54:
696:
362:
801:
773:
711:
676:
612:
454:
131:
778:
706:
656:
491:
1057:
960:
806:
786:
731:
1085:
869:
826:
821:
811:
721:
152:
119:
909:
894:
889:
746:
631:
577:
1031:
1010:
919:
816:
559:
511:
473:
79:
701:
544:
534:
529:
501:
496:
394:
1089:
337:
method can exit its guarded state and proceed with a call. Once the queue is empty, then the
1000:
741:
686:
607:
597:
587:
582:
175:
methods to assist with guarded suspension. In the implementation below, originally found in
990:
936:
914:
691:
646:
617:
592:
572:
519:
486:
462:
350:
156:
975:
836:
539:
524:
387:
1132:
796:
641:
602:
549:
1052:
1015:
904:
879:
671:
135:
325:
method that has a guard to detect when there are no items in the queue. Once the
1005:
980:
965:
884:
716:
21:
1077:
985:
423:
382:
321:
An example of an actual implementation would be a queue object with a
427:
15:
353:
is an alternative pattern for dealing with a precondition
1093:
1045:
1024:
953:
928:
845:
730:
630:
558:
510:
472:
461:
46:. Unsourced material may be challenged and removed.
386:
329:method notifies the other methods (for example, a
341:method will enter a guarded state once again.
1113:
439:
389:Concurrent Programming in Java Second Edition
8:
130:for managing operations that require both a
1120:
1106:
469:
446:
432:
424:
106:Learn how and when to remove this message
374:
176:
167:In Java, the Object class provides the
359:includes a similar language construct
7:
1074:
1072:
44:adding citations to reliable sources
1092:. You can help Knowledge (XXG) by
14:
1076:
20:
944:Enterprise Integration Patterns
393:. Reading, MA: Addison-Wesley.
31:needs additional citations for
1:
277:// Actual task implementation
1037:Portland Pattern Repository
1160:
1144:Computer programming stubs
1071:
298:// Change the object state
304:// Inform waiting threads
1139:Software design patterns
662:Event-based asynchronous
455:Software design patterns
357:Guarded Command Language
181:
568:Chain of responsibility
128:software design pattern
1088:-related article is a
707:Scheduled-task pattern
657:Double-checked locking
289:alterObjectStateMethod
120:concurrent programming
1058:Architectural pattern
961:Christopher Alexander
134:to be acquired and a
1086:computer-programming
870:Dependency injection
827:Inversion of control
822:Data transfer object
722:Thread-local storage
256:InterruptedException
55:"Guarded suspension"
40:improve this article
875:Intercepting filter
363:Readers–writer lock
235:// Continue to wait
1032:The Hillside Group
817:Data access object
667:Guarded suspension
652:Binding properties
333:method), then the
159:may be preferred.
124:guarded suspension
1101:
1100:
1066:
1065:
860:Business delegate
792:Publish–subscribe
626:
625:
116:
115:
108:
90:
1151:
1122:
1115:
1108:
1080:
1073:
865:Composite entity
742:Front controller
482:Abstract factory
470:
448:
441:
434:
425:
419:
405:
404:
392:
379:
340:
336:
332:
328:
324:
317:
314:
311:
308:
305:
302:
299:
296:
293:
290:
287:
284:
281:
278:
275:
272:
269:
266:
263:
260:
257:
254:
251:
248:
245:
242:
239:
236:
233:
230:
227:
224:
221:
218:
215:
212:
209:
206:
203:
200:
197:
194:
191:
188:
185:
174:
170:
143:) is satisfied.
111:
104:
100:
97:
91:
89:
48:
24:
16:
1159:
1158:
1154:
1153:
1152:
1150:
1149:
1148:
1129:
1128:
1127:
1126:
1069:
1067:
1062:
1041:
1020:
1011:Douglas Schmidt
991:Ward Cunningham
949:
937:Design Patterns
924:
915:Method chaining
847:
841:
802:Service locator
733:
726:
697:Read–write lock
633:
622:
613:Template method
554:
506:
464:
457:
452:
417:
414:
409:
408:
401:
381:
380:
376:
371:
351:Balking pattern
347:
338:
334:
330:
326:
322:
319:
318:
315:
312:
309:
306:
303:
300:
297:
294:
291:
288:
285:
282:
279:
276:
273:
270:
267:
264:
261:
258:
255:
252:
249:
246:
243:
240:
237:
234:
231:
228:
225:
222:
219:
216:
213:
210:
207:
204:
201:
198:
195:
192:
189:
186:
183:
172:
168:
165:
157:balking pattern
149:
112:
101:
95:
92:
49:
47:
37:
25:
12:
11:
5:
1157:
1155:
1147:
1146:
1141:
1131:
1130:
1125:
1124:
1117:
1110:
1102:
1099:
1098:
1081:
1064:
1063:
1061:
1060:
1055:
1049:
1047:
1043:
1042:
1040:
1039:
1034:
1028:
1026:
1022:
1021:
1019:
1018:
1013:
1008:
1003:
998:
993:
988:
983:
978:
976:John Vlissides
973:
968:
963:
957:
955:
951:
950:
948:
947:
940:
932:
930:
926:
925:
923:
922:
917:
912:
907:
902:
897:
892:
887:
882:
877:
872:
867:
862:
857:
851:
849:
843:
842:
840:
839:
834:
829:
824:
819:
814:
809:
804:
799:
794:
789:
784:
776:
771:
766:
765:
764:
759:
749:
744:
738:
736:
728:
727:
725:
724:
719:
714:
709:
704:
699:
694:
689:
684:
679:
674:
669:
664:
659:
654:
649:
644:
638:
636:
628:
627:
624:
623:
621:
620:
615:
610:
605:
600:
595:
590:
585:
580:
575:
570:
564:
562:
556:
555:
553:
552:
547:
542:
537:
532:
527:
522:
516:
514:
508:
507:
505:
504:
499:
494:
492:Factory method
489:
484:
478:
476:
467:
459:
458:
453:
451:
450:
443:
436:
428:
422:
421:
413:
410:
407:
406:
399:
373:
372:
370:
367:
366:
365:
360:
354:
346:
343:
182:
177:Kuchana (2004)
164:
163:Implementation
161:
151:Because it is
148:
145:
114:
113:
28:
26:
19:
13:
10:
9:
6:
4:
3:
2:
1156:
1145:
1142:
1140:
1137:
1136:
1134:
1123:
1118:
1116:
1111:
1109:
1104:
1103:
1097:
1095:
1091:
1087:
1082:
1079:
1075:
1070:
1059:
1056:
1054:
1051:
1050:
1048:
1044:
1038:
1035:
1033:
1030:
1029:
1027:
1023:
1017:
1014:
1012:
1009:
1007:
1004:
1002:
1001:Robert Martin
999:
997:
996:Martin Fowler
994:
992:
989:
987:
984:
982:
979:
977:
974:
972:
971:Ralph Johnson
969:
967:
964:
962:
959:
958:
956:
952:
946:
945:
941:
939:
938:
934:
933:
931:
927:
921:
918:
916:
913:
911:
908:
906:
903:
901:
898:
896:
893:
891:
888:
886:
883:
881:
878:
876:
873:
871:
868:
866:
863:
861:
858:
856:
853:
852:
850:
844:
838:
835:
833:
830:
828:
825:
823:
820:
818:
815:
813:
810:
808:
807:Active record
805:
803:
800:
798:
797:Naked objects
795:
793:
790:
788:
787:Specification
785:
783:
781:
777:
775:
772:
770:
767:
763:
760:
758:
755:
754:
753:
750:
748:
745:
743:
740:
739:
737:
735:
732:Architectural
729:
723:
720:
718:
715:
713:
710:
708:
705:
703:
700:
698:
695:
693:
690:
688:
685:
683:
680:
678:
675:
673:
670:
668:
665:
663:
660:
658:
655:
653:
650:
648:
645:
643:
642:Active object
640:
639:
637:
635:
629:
619:
616:
614:
611:
609:
606:
604:
601:
599:
596:
594:
591:
589:
586:
584:
581:
579:
576:
574:
571:
569:
566:
565:
563:
561:
557:
551:
548:
546:
543:
541:
538:
536:
533:
531:
528:
526:
523:
521:
518:
517:
515:
513:
509:
503:
500:
498:
495:
493:
490:
488:
485:
483:
480:
479:
477:
475:
471:
468:
466:
460:
456:
449:
444:
442:
437:
435:
430:
429:
426:
416:
415:
411:
402:
400:0-201-31009-0
396:
391:
390:
384:
378:
375:
368:
364:
361:
358:
355:
352:
349:
348:
344:
342:
202:guardedMethod
180:
178:
162:
160:
158:
154:
146:
144:
142:
137:
133:
129:
125:
121:
110:
107:
99:
96:December 2010
88:
85:
81:
78:
74:
71:
67:
64:
60:
57: –
56:
52:
51:Find sources:
45:
41:
35:
34:
29:This article
27:
23:
18:
17:
1094:expanding it
1083:
1068:
1053:Anti-pattern
1016:Linda Rising
942:
935:
880:Lazy loading
812:Identity map
779:
666:
463:Gang of Four
388:
377:
320:
283:synchronized
220:preCondition
196:synchronized
166:
150:
136:precondition
123:
117:
102:
93:
83:
76:
69:
62:
50:
38:Please help
33:verification
30:
1025:Communities
1006:Jim Coplien
981:Grady Booch
966:Erich Gamma
910:Type tunnel
895:Object pool
890:Null object
885:Mock object
747:Interceptor
717:Thread pool
632:Concurrency
578:Interpreter
1133:Categories
920:Delegation
855:Blackboard
560:Behavioral
512:Structural
474:Creational
412:References
66:newspapers
986:Kent Beck
712:Semaphore
702:Scheduler
545:Flyweight
535:Decorator
530:Composite
502:Singleton
497:Prototype
383:Lea, Doug
1046:See also
848:patterns
734:patterns
687:Proactor
634:patterns
608:Strategy
598:Observer
588:Mediator
583:Iterator
465:patterns
385:(2000).
345:See also
173:notify()
153:blocking
900:Servant
832:Model 2
692:Reactor
682:Monitor
647:Balking
618:Visitor
593:Memento
573:Command
520:Adapter
487:Builder
190:Example
80:scholar
954:People
837:Broker
540:Facade
525:Bridge
397:
307:notify
184:public
169:wait()
82:
75:
68:
61:
53:
1084:This
929:Books
846:Other
782:-tier
603:State
550:Proxy
369:Notes
250:catch
211:while
187:class
147:Usage
141:guard
126:is a
87:JSTOR
73:books
1090:stub
905:Twin
762:MVVM
677:Lock
672:Join
395:ISBN
301:// …
286:void
268:// …
244:// …
238:wait
199:void
171:and
132:lock
59:news
774:ECS
769:ADR
757:MVP
752:MVC
339:get
335:get
331:get
327:put
323:get
310:();
241:();
229:try
223:())
118:In
42:by
1135::
292:()
205:()
122:,
1121:e
1114:t
1107:v
1096:.
780:n
447:e
440:t
433:v
420:.
403:.
316:}
313:}
295:{
280:}
274:}
271:}
265:{
262:)
259:e
253:(
247:}
232:{
226:{
217:!
214:(
208:{
193:{
109:)
103:(
98:)
94:(
84:·
77:·
70:·
63:·
36:.
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.