多个线程可以同时使用相同的PrintWriter吗?
Is it OK for multiple threads to use the same PrintWriter concurrently?
推荐答案" Jeff Schwab" < JE ****** @ comcast>在消息中写道 新闻:rY ******************** @ comcast ... "Jeff Schwab" <je******@comcast> wrote in message news:rY********************@comcast... 是可以让多个线程同时使用同一个PrintWriter吗? Is it OK for multiple threads to use the same PrintWriter concurrently?
在这种情况下你会考虑线程安全行为吗? Silvio Bierman
What would you consider threadsafe behaviour in such a scenario? Silvio Bierman
Silvio Bierman写道: Silvio Bierman wrote: " Jeff Schwab" < JE ****** @ comcast>在消息中写道新闻:rY ******************** @ comcast ... "Jeff Schwab" <je******@comcast> wrote in message news:rY********************@comcast... 是多个线程可以同时使用相同的PrintWriter吗? Is it OK for multiple threads to use the same PrintWriter concurrently?
在这种情况下你会考虑线程安全行为吗?
What would you consider threadsafe behaviour in such a scenario?
好问题。我只是想确保I / O系统不会被混淆。如果两个线程的输出交织在一起就没关系。
Good question. I just want to make sure the I/O system won''t get confused. It''s OK if the output of the two threads is intertwined.
你是否介意单词或单词中的字符是否混合? 线程1试图打印线程1 ABCDEF 线程2试图打印线程2 GHIJKLM 以下是OK ? " TThhr 1 eadAe 2a GHd ABCIJKLMDEF" 我认为您应该同步实际的IO调用。我们所做的是利用一个 消息队列; 不同的线程丢弃队列中的消息对象,而低优先级的线程等待<队列中的,弹出消息,执行IO,然后等待下一个 消息。因此只有一个低优先级的线程实际上正在执行IO。 Jeff Schwab < JE ****** @ comcast>在消息中写道 news:eu ******************** @ comcast ... Do you mind if characters within words or words are mixed? Thread 1 trys to print "Thread 1 ABCDEF" Thread 2 trys to print "Thread 2 GHIJKLM" Is the following OK? "TThhr 1 eadAe 2a GHd ABCIJKLMDEF" I think you should synchronize the actual IO call. What we do is utilize a message queue; the different threads drop message objects in the queue while a low-priority thread waits on the queue, pops off a message, does the IO, then waits for the next message. So only one, low-priority, thread is actually doing the IO. "Jeff Schwab" <je******@comcast> wrote in message news:eu********************@comcast... Silvio Bierman写道: Silvio Bierman wrote: " Jeff Schwab" < JE ****** @ comcast>在消息中写道新闻:rY ******************** @ comcast ... "Jeff Schwab" <je******@comcast> wrote in message news:rY********************@comcast... 是多个线程可以同时使用相同的PrintWriter吗? Is it OK for multiple threads to use the same PrintWriter concurrently?
在这种情况下你会考虑线程安全行为?
What would you consider threadsafe behaviour in such a scenario?
好问题。我只是想确保I / O系统不会混淆。如果两个线程的输出交织在一起就没关系。
Good question. I just want to make sure the I/O system won''t get confused. It''s OK if the output of the two threads is intertwined.
~让我们linux~ ----- =通过新闻源发布。 Com,Uncensored Usenet News = ----- www.newsfeeds - 世界排名第一的新闻组服务! ----- ==超过100,000个新闻组--19个不同的服务器! = -----
~ Let us linux ~ -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- www.newsfeeds - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
更多推荐
PrintWriter线程安全吗?
发布评论