Results 21 to 21 of 21
Thread: Java Threads Interview Question
- 12-22-2008, 08:31 AM #21
Member
- Join Date
- Dec 2008
- Posts
- 1
- Rep Power
- 0
It seems that the best solution here is to place a synchronized block around the while statement
It doesn't have to be MyAnswer.class object, you can create any class level object as long it's not "synchronized(this)" or any private member of the thread instanceJava Code:synchronized(MyAnswer.class){ while (n<100) { System.out.print(str); System.out.println(); n++; } }
Similar Threads
-
threads question
By sandor in forum Threads and SynchronizationReplies: 9Last Post: 02-07-2009, 08:57 PM -
Job Interview About J2EE 2007
By pazuvn in forum Advanced JavaReplies: 1Last Post: 05-14-2008, 02:45 AM -
We need Java Programmers to interview
By jayson_sabale in forum Forum LobbyReplies: 4Last Post: 05-05-2008, 09:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks