diff --git a/CodenameOne/src/com/codename1/charts/models/XYSeries.java b/CodenameOne/src/com/codename1/charts/models/XYSeries.java index 0b95a42cd4..b3be28a917 100644 --- a/CodenameOne/src/com/codename1/charts/models/XYSeries.java +++ b/CodenameOne/src/com/codename1/charts/models/XYSeries.java @@ -148,7 +148,7 @@ public void setTitle(String title) { * @param x the value for the X axis * @param y the value for the Y axis */ - public synchronized void add(double x, double y) { + public void add(double x, double y) { while (mXY.get(x) != null) { // add a very small value to x such as data points sharing the same x will // still be added @@ -165,7 +165,7 @@ public synchronized void add(double x, double y) { * @param x the value for the X axis * @param y the value for the Y axis */ - public synchronized void add(int index, double x, double y) { + public void add(int index, double x, double y) { while (mXY.get(x) != null) { // add a very small value to x such as data points sharing the same x will // still be added @@ -184,7 +184,7 @@ protected double getPadding(double x) { * * @param index the index in the series of the value to remove */ - public synchronized void remove(int index) { + public void remove(int index) { XYEntry removedEntry = mXY.removeByIndex(index); double removedX = removedEntry.getKey(); double removedY = removedEntry.getValue(); @@ -196,7 +196,7 @@ public synchronized void remove(int index) { /** * Removes all the existing values and annotations from the series. */ - public synchronized void clear() { + public void clear() { clearAnnotations(); clearSeriesValues(); } @@ -204,7 +204,7 @@ public synchronized void clear() { /** * Removes all the existing values from the series but annotations. */ - public synchronized void clearSeriesValues() { + public void clearSeriesValues() { mXY.clear(); initRange(); } @@ -212,17 +212,17 @@ public synchronized void clearSeriesValues() { /** * Removes all the existing annotations from the series. */ - public synchronized void clearAnnotations() { - mStringXY.clear(); - mAnnotations.clear(); - } + public void clearAnnotations() { + mStringXY.clear(); + mAnnotations.clear(); + } /** * Returns the current values that are used for drawing the series. * * @return the XY map */ - public synchronized IndexXYMap getXYMap() { + public IndexXYMap getXYMap() { return mXY; } @@ -232,7 +232,7 @@ public synchronized IndexXYMap getXYMap() { * @param index the index * @return the X value */ - public synchronized double getX(int index) { + public double getX(int index) { return mXY.getXByIndex(index); } @@ -242,7 +242,7 @@ public synchronized double getX(int index) { * @param index the index * @return the Y value */ - public synchronized double getY(int index) { + public double getY(int index) { return mXY.getYByIndex(index); } @@ -335,7 +335,7 @@ public String getAnnotationAt(int index) { * visible ones must be displayed * @return a submap of x and y values */ - public synchronized SortedMap getRange(double start, double stop, + public SortedMap getRange(double start, double stop, boolean beforeAfterPoints) { if (beforeAfterPoints) { // we need to add one point before the start and one point after the end @@ -379,7 +379,7 @@ public int getIndexForKey(double key) { * * @return the series item count */ - public synchronized int getItemCount() { + public int getItemCount() { return mXY.size(); } diff --git a/CodenameOne/src/com/codename1/charts/models/XYValueSeries.java b/CodenameOne/src/com/codename1/charts/models/XYValueSeries.java index 81243cdc00..70f8d2e857 100644 --- a/CodenameOne/src/com/codename1/charts/models/XYValueSeries.java +++ b/CodenameOne/src/com/codename1/charts/models/XYValueSeries.java @@ -48,7 +48,7 @@ public XYValueSeries(String title) { * @param y the value for the Y axis * @param value the value */ - public synchronized void add(double x, double y, double value) { + public void add(double x, double y, double value) { super.add(x, y); mValue.add(value); updateRange(value); @@ -82,7 +82,7 @@ private void updateRange(double value) { * @param x the value for the X axis * @param y the value for the Y axis */ - public synchronized void add(double x, double y) { + public void add(double x, double y) { add(x, y, 0d); } @@ -91,7 +91,7 @@ public synchronized void add(double x, double y) { * * @param index the index in the series of the value to remove */ - public synchronized void remove(int index) { + public void remove(int index) { super.remove(index); double removedValue = mValue.remove(index); if (removedValue == mMinValue || removedValue == mMaxValue) { @@ -102,7 +102,7 @@ public synchronized void remove(int index) { /** * Removes all the values from the series. */ - public synchronized void clear() { + public void clear() { super.clear(); mValue.clear(); initRange(); @@ -114,7 +114,7 @@ public synchronized void clear() { * @param index the index * @return the value */ - public synchronized double getValue(int index) { + public double getValue(int index) { return mValue.get(index); } diff --git a/CodenameOne/src/com/codename1/io/BufferedInputStream.java b/CodenameOne/src/com/codename1/io/BufferedInputStream.java index 6f7c945d88..2214292292 100644 --- a/CodenameOne/src/com/codename1/io/BufferedInputStream.java +++ b/CodenameOne/src/com/codename1/io/BufferedInputStream.java @@ -34,7 +34,7 @@ */ public class BufferedInputStream extends InputStream { private static int streamCount = 0; - private static int defaultBufferSize = 8192; + private static volatile int defaultBufferSize = 8192; private int actualAvailable = defaultBufferSize; private Object connection; private InputStream in; @@ -212,10 +212,10 @@ public String getName() { } /** - * Check to make sure that underlying input stream has not been + * Check to make sure that the underlying input stream has not been * nulled out due to close; if not return it; */ - private InputStream getInIfOpen() throws IOException { + private synchronized InputStream getInIfOpen() throws IOException { InputStream input = in; if (input == null) { throw new IOException("Stream closed"); @@ -227,7 +227,7 @@ private InputStream getInIfOpen() throws IOException { * Check to make sure that buffer has not been nulled out due to * close; if not return it; */ - private byte[] getBufIfOpen() throws IOException { + private synchronized byte[] getBufIfOpen() throws IOException { byte[] buffer = buf; if (buffer == null) { throw new IOException("Stream closed"); @@ -377,7 +377,7 @@ private int read1(byte[] b, int off, int len) throws IOException { return cnt; } - private void yieldTime() { + private synchronized void yieldTime() { long time = System.currentTimeMillis(); if (time - elapsedSinceLastYield > 300) { try { @@ -656,16 +656,16 @@ public void close() throws IOException { * * @return time of the last activity on this stream */ - public long getLastActivityTime() { + public synchronized long getLastActivityTime() { return lastActivityTime; } /** - * Returns the total amount of bytes read from this stream so far + * Returns the total number of bytes read from this stream so far * - * @return the total amount of bytes read from this stream so far + * @return the total number of bytes read from this stream so far */ - public int getTotalBytesRead() { + public synchronized int getTotalBytesRead() { return totalBytesRead; } @@ -706,14 +706,14 @@ public void setConnection(Object connection) { /** * @return the disableBuffering */ - public boolean isDisableBuffering() { + public synchronized boolean isDisableBuffering() { return disableBuffering; } /** * @param disableBuffering the disableBuffering to set */ - public void setDisableBuffering(boolean disableBuffering) { + public synchronized void setDisableBuffering(boolean disableBuffering) { this.disableBuffering = disableBuffering; } @@ -723,7 +723,7 @@ public void setDisableBuffering(boolean disableBuffering) { * * @return the printInput */ - public boolean isPrintInput() { + public synchronized boolean isPrintInput() { return printInput; } @@ -733,7 +733,7 @@ public boolean isPrintInput() { * * @param printInput the printInput to set */ - public void setPrintInput(boolean printInput) { + public synchronized void setPrintInput(boolean printInput) { this.printInput = printInput; } @@ -743,7 +743,7 @@ public void setPrintInput(boolean printInput) { * * @return the yield */ - public int getYield() { + public synchronized int getYield() { return yield; } @@ -753,7 +753,7 @@ public int getYield() { * * @param yield the yield to set */ - public void setYield(int yield) { + public synchronized void setYield(int yield) { this.yield = yield; } @@ -761,7 +761,7 @@ public void setYield(int yield) { * Stop reading from the stream, invoking this will cause the read() to * return -1 */ - public void stop() { + public synchronized void stop() { stopped = true; } diff --git a/CodenameOne/src/com/codename1/io/BufferedOutputStream.java b/CodenameOne/src/com/codename1/io/BufferedOutputStream.java index d14680bbe1..0536ec40e1 100644 --- a/CodenameOne/src/com/codename1/io/BufferedOutputStream.java +++ b/CodenameOne/src/com/codename1/io/BufferedOutputStream.java @@ -137,7 +137,7 @@ public String getName() { /** * Flush the internal buffer */ - public void flushBuffer() throws IOException { + public synchronized void flushBuffer() throws IOException { if (closed) { return; } @@ -218,7 +218,7 @@ public synchronized void flush() throws IOException { * * @return time of the last activity on this stream */ - public long getLastActivityTime() { + public synchronized long getLastActivityTime() { return lastActivityTime; } @@ -227,7 +227,7 @@ public long getLastActivityTime() { * * @return the total amount of bytes written to this stream so far */ - public int getTotalBytesWritten() { + public synchronized int getTotalBytesWritten() { return totalBytesWritten; } diff --git a/CodenameOne/src/com/codename1/l10n/DateFormatSymbols.java b/CodenameOne/src/com/codename1/l10n/DateFormatSymbols.java index f66a7ed3e8..6e4c8f4bfa 100644 --- a/CodenameOne/src/com/codename1/l10n/DateFormatSymbols.java +++ b/CodenameOne/src/com/codename1/l10n/DateFormatSymbols.java @@ -90,12 +90,14 @@ public void setAmPmStrings(String[] newAmpms) { ampms = newAmpms; } - public Hashtable getResourceBundle() { + public synchronized Hashtable getResourceBundle() { return resourceBundle; } public void setResourceBundle(Hashtable newResourceBundle) { - this.resourceBundle = newResourceBundle; + synchronized (this) { + this.resourceBundle = newResourceBundle; + } // force rebuild ampms = null; months = null; diff --git a/CodenameOne/src/com/codename1/ui/Display.java b/CodenameOne/src/com/codename1/ui/Display.java index 7819459c59..82c02fecd5 100644 --- a/CodenameOne/src/com/codename1/ui/Display.java +++ b/CodenameOne/src/com/codename1/ui/Display.java @@ -2919,7 +2919,7 @@ public void setVirtualKeyboardListener(ActionListener l) { * @see #removeVirtualKeyboardListener(com.codename1.ui.events.ActionListener) * @since 6.0 */ - public synchronized void addVirtualKeyboardListener(ActionListener l) { + public void addVirtualKeyboardListener(ActionListener l) { if (virtualKeyboardListeners == null) { virtualKeyboardListeners = new EventDispatcher(); } @@ -2937,7 +2937,7 @@ public synchronized void addVirtualKeyboardListener(ActionListener l) { * @see #addVirtualKeyboardListener(com.codename1.ui.events.ActionListener) * @since 6.0 */ - public synchronized void removeVirtualKeyboardListener(ActionListener l) { + public void removeVirtualKeyboardListener(ActionListener l) { if (virtualKeyboardListeners != null) { virtualKeyboardListeners.removeListener(l); } @@ -3422,7 +3422,7 @@ public void dispatchMessage(MessageEvent evt) { * * @param l the listener to add */ - public synchronized void addWindowListener(ActionListener l) { + public void addWindowListener(ActionListener l) { if (windowListeners == null) { windowListeners = new EventDispatcher(); } @@ -3434,7 +3434,7 @@ public synchronized void addWindowListener(ActionListener l) { * * @param l the listener to remove */ - public synchronized void removeWindowListener(ActionListener l) { + public void removeWindowListener(ActionListener l) { if (windowListeners != null) { windowListeners.removeListener(l); } @@ -5222,7 +5222,7 @@ private class EdtException extends RuntimeException { private Throwable cause; private EdtException parent; - public synchronized Throwable getCause() { + public Throwable getCause() { return cause; } diff --git a/CodenameOne/src/com/codename1/ui/Image.java b/CodenameOne/src/com/codename1/ui/Image.java index 00198dd5a7..1edf86f690 100644 --- a/CodenameOne/src/com/codename1/ui/Image.java +++ b/CodenameOne/src/com/codename1/ui/Image.java @@ -1576,7 +1576,7 @@ public boolean requiresDrawImage() { } @Override - public synchronized void addActionListener(ActionListener l) { + public void addActionListener(ActionListener l) { if (listeners == null) { listeners = new EventDispatcher(); } @@ -1584,7 +1584,7 @@ public synchronized void addActionListener(ActionListener l) { } @Override - public synchronized void removeActionListener(ActionListener l) { + public void removeActionListener(ActionListener l) { if (listeners != null) { listeners.removeListener(l); } diff --git a/CodenameOne/src/com/codename1/ui/html/ResourceThreadQueue.java b/CodenameOne/src/com/codename1/ui/html/ResourceThreadQueue.java index d8808f0690..0aebe3f6f6 100644 --- a/CodenameOne/src/com/codename1/ui/html/ResourceThreadQueue.java +++ b/CodenameOne/src/com/codename1/ui/html/ResourceThreadQueue.java @@ -186,7 +186,7 @@ synchronized int getCSSCount() { * * @return the queue size */ - int getQueueSize() { + synchronized int getQueueSize() { return (images.size() + queue.size()); // CSS files are added directly to queue while images to the images vector //return queue.size(); }