TextWriter synchronized method

  • Thread starter Thread starter fniles
  • Start date Start date
F

fniles

If I use TextWriter synchronized method like below codes if another thread
is trying to write at the same time, what will happen ? Will it the 2nd
thread request to write to the file be queued ? Will the 2nd thread then
stop processing other codes while waiting to write to this file ?

Thank you.

Dim swLogOrig As StreamWriter
Dim swLog As TextWriter

swLogOrig = New StreamWriter(m_sLogFileName, True)
swLog = TextWriter.Synchronized(swLogOrig)
 
If I use TextWriter synchronized method like below codes if another
thread is trying to write at the same time, what will happen ?

I believe it will block until the first thread releases the write.


Synchronized methods implement a simple synclock mechanism if I'm not
mistaken.
 
so if you use the sychronized, you don't have to lock?
will it automatically queue the next calls for that specific textwriter?
 
Back
Top