Redian新闻
>
[GONE] Reviewer wanted [Renal function, Hemodynamics]
avatar
[GONE] Reviewer wanted [Renal function, Hemodynamics]# Immigration - 落地生根
b*5
1
You are writing a simulation for a print server. This print
server can accept jobs from 3 places - network, USB, or operator. It can
dispatch only one job at a time. Each input job should contain an integer t
which is the time in seconds it will take to process the job. Write a multi-
threaded program to simulate the server and provide some simulated load with
jobs. Think, of some interesting statistics your program should emit and
code them in.
avatar
s*y
2
I got an invitation but have no time to do it at this time. If anyone wants
it, I may make a suggestion to the editor. Please msg me your CV ASAP.
However, please do note that I won't be able to guarantee if the editor
would take my recommendation.
avatar
b*5
3
Up
avatar
n*s
4
招个新人做
avatar
e*2
5
不会。

t
multi-
with

【在 b**********5 的大作中提到】
: You are writing a simulation for a print server. This print
: server can accept jobs from 3 places - network, USB, or operator. It can
: dispatch only one job at a time. Each input job should contain an integer t
: which is the time in seconds it will take to process the job. Write a multi-
: threaded program to simulate the server and provide some simulated load with
: jobs. Think, of some interesting statistics your program should emit and
: code them in.

avatar
b*5
6
up, 一家的online test。。。 除了这题, 他妈的还有其他三道题。。。 要45分钟
做完。。
avatar
g*g
7
Use a blocking queue, this is a typical producer/consumer multi-thread
question.

t
multi-
with

【在 b**********5 的大作中提到】
: You are writing a simulation for a print server. This print
: server can accept jobs from 3 places - network, USB, or operator. It can
: dispatch only one job at a time. Each input job should contain an integer t
: which is the time in seconds it will take to process the job. Write a multi-
: threaded program to simulate the server and provide some simulated load with
: jobs. Think, of some interesting statistics your program should emit and
: code them in.

avatar
b*5
8
I know u need a queue, but how do u write USB...sockets and shit? and then
should I use a registed callback to do statistics like actual time used to
process tasks?


【在 g*****g 的大作中提到】
: Use a blocking queue, this is a typical producer/consumer multi-thread
: question.
:
: t
: multi-
: with

avatar
g*g
9
No, it's called simulation, all you need is label the producers as "USB"
blah blah and print out as such. You register the timestamp when the job is
produced and calculate the diff when the job is consumed, it's exactly the
basic P/C question.

【在 b**********5 的大作中提到】
: I know u need a queue, but how do u write USB...sockets and shit? and then
: should I use a registed callback to do statistics like actual time used to
: process tasks?
:

avatar
g*g
10
Executors.newFixedThreadPool(1);
class PrintTask extends Callable {
public PrintTask(DeviceEnum device, int printTime);
}
record current timestamp and use finish time to come up with statistics is
enough.
Not rocket science.
avatar
b*5
11
are you saying the following is enough??!!!
public class Printer {
main () {
BlocingQueue q...
Thread USBThread = new Thread (new Producer(q));
Thread USB1Thread = new Thread (new Producer(q));

Thread consumerThread = new Thread (new Consumer(q));

thread.starts();
thread.start(); ...
}
}
then the USBthread just add dummy tasks to the queue??! I just create a
dummy class Task? I don't need no bytestreams or shit like that?!
and in the consumer thread, just take one by one?

【在 b**********5 的大作中提到】
: I know u need a queue, but how do u write USB...sockets and shit? and then
: should I use a registed callback to do statistics like actual time used to
: process tasks?
:

avatar
b*5
12
got it. thanks. so just a simulation with one consumer and producer thread
.

【在 g*****g 的大作中提到】
: Executors.newFixedThreadPool(1);
: class PrintTask extends Callable {
: public PrintTask(DeviceEnum device, int printTime);
: }
: record current timestamp and use finish time to come up with statistics is
: enough.
: Not rocket science.

avatar
g*g
13
No, it's one consumer and any number of producers.

thread

【在 b**********5 的大作中提到】
: got it. thanks. so just a simulation with one consumer and producer thread
: .

avatar
b*5
14
? So i am assuming it will be a queue of PrintTask u defined above.
So are u saying i should start 3 producer threads for 3 devices? But if u
already include device enum in the printtask, then why do u need 3 different
threads for each?

【在 g*****g 的大作中提到】
: No, it's one consumer and any number of producers.
:
: thread

avatar
g*g
15
You don't need to start any producer thread. threadpool is about consumer.
An enum is enough to mark the producer.

different

【在 b**********5 的大作中提到】
: ? So i am assuming it will be a queue of PrintTask u defined above.
: So are u saying i should start 3 producer threads for 3 devices? But if u
: already include device enum in the printtask, then why do u need 3 different
: threads for each?

avatar
b*5
16
now i am back to square one... if u not gonna have any producer thread, then
how is the queue of PrintTasks getting added?

【在 g*****g 的大作中提到】
: You don't need to start any producer thread. threadpool is about consumer.
: An enum is enough to mark the producer.
:
: different

avatar
d*p
17
Operator, USB and network should take care of producing tasks. Printer can
provide a function to accept these tasks and insert into queue.
avatar
g*g
18
For simulation,you just need to demonstrate the ability submit each task
asynchronously. That's why each task is a callable future.
e.g.
Future f = threadpool.submit(new PrintTask(USB, 10));

different

【在 b**********5 的大作中提到】
: ? So i am assuming it will be a queue of PrintTask u defined above.
: So are u saying i should start 3 producer threads for 3 devices? But if u
: already include device enum in the printtask, then why do u need 3 different
: threads for each?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。