c# - What is difference between Task and Thread? -
today digging tpl , found new class task.now wanted know diffrence between task , thread,and 1 better?
what diffrence between task , thread?
suppose running book delivery company. have 4 cars , 4 drivers. car thread, driver processor, , book delivery task. problem face how efficiently schedule drivers , cars tasks done possible.
where things weird when there more cars (threads) drivers (processors). happens halfway through trip driver parks 1 car (suspends thread) , gets different car (switches context), drives 1 around while performing tasks, , comes first car. not efficient 1 driver staying in 1 car.
the idea of task-based parallism break work small tasks can produce results in future, , efficiently allocate many threads there processors don't waste time context switching. in practice, not work out nicely, that's idea.
which 1 better, task or thread?
the question cannot answered because doesn't make sense. better, book deliver customer, or car deliver in? car device can used deliver book; 2 things not things can sensibly describe "better" or "worse" other. it's asking "which better, hole or drill?"
Comments
Post a Comment