@@ -105,13 +105,14 @@ public final String update(final String sessionId) throws ApplicationException,
105
105
Builder message ;
106
106
Queue <Builder > messages ;
107
107
synchronized (this .list ) {
108
- do {
108
+ messages = this .list .get (sessionId );
109
+ while ((message = messages .poll ()) == null ) {
109
110
try {
110
111
this .list .wait (TIMEOUT );
111
112
} catch (InterruptedException e ) {
112
113
throw new ApplicationException (e .getMessage (), e );
113
114
}
114
- } while (( messages = this . list . get ( sessionId )) == null || ( message = messages . poll ()) == null );
115
+ }
115
116
116
117
return message .toString ();
117
118
}
@@ -144,12 +145,12 @@ private final void copy(Object meetingCode, Builder builder) {
144
145
}
145
146
}
146
147
}
147
-
148
+
148
149
@ Override
149
150
public String version () {
150
151
return "Welcome to use tinystruct 2.0" ;
151
152
}
152
-
153
+
153
154
public static void main (String [] args ) throws ApplicationException {
154
155
talk talk = new talk ();
155
156
talk .meetings .put ("[M001]" , new ConcurrentLinkedQueue <Builder >());
@@ -161,12 +162,12 @@ public static void main(String[] args) throws ApplicationException {
161
162
sess .add ("{B}" );
162
163
talk .sessions .put ("[M001]" , sess );
163
164
ApplicationManager .install (talk );
164
-
165
+ final int n = 1000 ;
165
166
new Thread (new Runnable (){
166
167
@ Override
167
168
public void run () {
168
169
int i =0 ;
169
- while (i ++<200 )
170
+ while (i ++<n )
170
171
try {
171
172
ApplicationManager .call ("talk/save/[M001]/{A}/A post " +i , null );
172
173
Thread .sleep (1 );
@@ -184,7 +185,7 @@ public void run() {
184
185
@ Override
185
186
public void run () {
186
187
int i =0 ;
187
- while (i ++<200 )
188
+ while (i ++<n )
188
189
try {
189
190
ApplicationManager .call ("talk/save/[M001]/{B}/B post " +i , null );
190
191
Thread .sleep (1 );
0 commit comments