-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Анна Власова, 496: Threads + CQL + CQLex + TwitterStream + ModuleTests #72
base: master
Are you sure you want to change the base?
Conversation
numberOfThreads = num; | ||
} | ||
|
||
private final int myNumber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сначала пишут все поля, потом все методы, исправьте и в других местах
while (myNumber != currentThread) { | ||
Thread.yield(); | ||
} | ||
System.out.println("Thread-" + (myNumber + 1) + "\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println за вас строчку переводит, не нужно \n добавлять
Блокирующую очередь нужно протестировать |
synchronized List<T> take(int n, long timeout) { | ||
timeout += System.currentTimeMillis(); | ||
while ((data.size() < n) && (timeout - System.currentTimeMillis()) > 0) { | ||
Thread.yield(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это слишком общая функция, поток будет просыпаться чаще чем нужно.
Для синхронизации лучше использовать блоки synchronized и методы
Object.wait(long timeout) / notifyAll(), или может что-то еще, но потоки должны просыпаться по нашему указанию, а не т любого шороха.
No description provided.