Java call function from multiple threads not declared thread safe

There is a JDK function which, although javadocs does not declare it thread safe, looking at the code on Google, it seems that I can get the result I want by calling it from multiple threads without unwanted side effects, since the function uses mainly stack variables. Therefore, it does not matter if it has synchronized blocks. I wonder if I am missing something and in the end run into trouble. Function - connection.call (requestMsg, url); SOAPConnection by SAAJ api. Any pointer to how I should parse this to decide whether to use it from multiple threads or not?

Thank!

+3
source share
4 answers

Below is a quote from "How to Write Doc Comments for the Javadoc Tool"

The Java platform API specification is a contract between callers and implementations.

, . , , . ( ) , . "" (.. ). , .

, , Java API , . , , . , API Swing .

, , , :

  • javadoc , - , , .
  • javadoc , - , , .
  • javadoc , , , , .
  • javadoc , , , . javadoc .

( , Sun/Oracle , . API- concurrency... , , ).

+1

. , . Sun, Vector, Hashtable, StringBuffer, Java . . java concurrency.

, . , . . ( ).

, , , . , "". , , concurrency.

. .

-

,

constructor()
  open socket

Response call(Request)
  write request to socket output stream
  read response from socket input stream

close()
  close socket

() , , UNSAFE. / TCP-, .

, , ? . , (); ; ; ; close() ; x , ; ; , (), excpetion.

+4

. , Thread Safe, , . , 15- .

, , - , . , , , , , .

, , , , , , 100% .

: - : " ?, ?"

, .

+1

A general rule is that methods and classes are thread safe unless otherwise indicated. So, for example, RMI methods are thread safe, the same.

-3
source

Source: https://habr.com/ru/post/1758594/


All Articles