true
My Element in stack 90
My Element in stack 91
i am consuming the element-->My Element in stack 90 from the produced stack
i am consuming the element-->My Element in stack 91 from the produced stack
My Element in stack 92
My Element in stack 93
My Element in stack 94
My Element in stack 95
i am consuming the element-->My Element in stack 92 from the produced stack
i am consuming the element-->My Element in stack 93 from the produced stack
i am consuming the element-->My Element in stack 94 from the produced stack
i am consuming the element-->My Element in stack 95 from the produced stack
My Element in stack 96
My Element in stack 97
My Element in stack 98
My Element in stack 99
i am consuming the element-->My Element in stack 96 from the produced stack
My Element in stack 100
i am consuming the element-->My Element in stack 97 from the produced stack
My Element in stack 101
i am consuming the element-->My Element in stack 98 from the produced stack
My Element in stack 102
i am consuming the element-->My Element in stack 99 from the produced stack
My Element in stack 103
i am consuming the element-->My Element in stack 100 from the produced stack
My Element in stack 104
i am consuming the element-->My Element in stack 101 from the produced stack
My Element in stack 105
i am consuming the element-->My Element in stack 102 from the produced stack
My Element in stack 106
i am consuming the element-->My Element in stack 103 from the produced stack
My Element in stack 107
i am consuming the element-->My Element in stack 104 from the produced stack
My Element in stack 108
i am consuming the element-->My Element in stack 105 from the produced stack
My Element in stack 109
i am consuming the element-->My Element in stack 106 from the produced stack
My Element in stack 110
My Element in stack 111
i am consuming the element-->My Element in stack 107 from the produced stack
i am consuming the element-->My Element in stack 108 from the produced stack
i am consuming the element-->My Element in stack 109 from the produced stack
i am consuming the element-->My Element in stack 110 from the produced stack
My Element in stack 112
My Element in stack 113
i am consuming the element-->My Element in stack 111 from the produced stack
i am consuming the element-->My Element in stack 112 from the produced stack
My Element in stack 114
i am consuming the element-->My Element in stack 113 from the produced stack
My Element in stack 115
i am consuming the element-->My Element in stack 114 from the produced stack
My Element in stack 116
i am consuming the element-->My Element in stack 115 from the produced stack
My Element in stack 117
i am consuming the element-->My Element in stack 116 from the produced stack
i am consuming the element-->My Element in stack 117 from the produced stack
My Element in stack 118
My Element in stack 119
i am consuming the element-->My Element in stack 118 from the produced stack
My Element in stack 120
i am consuming the element-->My Element in stack 119 from the produced stack
i am consuming the element-->My Element in stack 120 from the produced stack
My Element in stack 121
My Element in stack 122
My Element in stack 123
Steve
My producer class : the condition that i have given for checking is- if in any condition , the stack returns that the stack is full then the producer throws an exception stating that the stack is not waiting for consumption.
Steve
Steve
This check only happens once, when the run() method starts, and the isFull() method is not safe so it can not be relied on. This would only work as a check if the stack were full before the producer was started.
Not sure if defining and returning the element outside the synchronized block is the right thing to do. It doesn't save you anything, and sets you up to use the same paradigm later when it will cause a problem. I would avoid it
If an interruption occurs, then you can progress through the method while the list is past capacity. You should change the if(isFull()) to while(isFull()) so, even if interrupted, the method won't progress.
Whenever possible, for multi-threaded state, make things final. In this case, both list and maxSize should be final
Stanley Walker wrote:Please help with a condition/check which will underline that the producer consumer problem is not solved.
Do you mean that if i want to write thread safe classes i should make all my instance variables as final?
Steve
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |