Can multithreading be implemented on a single processor system?
Yes, you totally can. Ages ago (Win 95?) we went from Cooperative Multitasking to Multithreading, because someone always screwed up the cooperative part. Every programm on your computer has at least one thread. Possibly more. And the CPU keep just switching between those all those threads like mad a few million times per second. If none of them has anything to do, it might even go idle for some time.
Multicore systems only mean that two or more of those threads might run in paralell.
However, it brings you a lot less to do so. All you can do with Multithreading on a Single Core machine is simulate Multitasking.
Mulitasking is enough to prevent the GUI thread from locking up because of a longrunning operation. However it is generally complicated to implement, unless you have some help from the Compiler or Langauge (like C# async...await). As a result, many GUI programmer just used Multithreading and Invoking to fake multitasking. If that code runs on single or multiple core does not mater for this.
Most importantly, Multitasking is NOT suited for CPU bound operations. But 95% of all Async problems are not CPU bound. They are Network or Disk Bound. On a singlecore computer, Multithreading also does not help with CPU bound stuff. If you got two threads that both need 100% CPU time (same programm or different one) but only one core to run them on, the CPU will just have to switch between running both at 49% and use the remaining 2% for all those other threads that only do a little bit.
Finally only very few problems can actually be Multithreaded. Just try to multithread the Fibonacci Sequence (one thread for each pair) without making it slower, more memory demanding and more complex.
tl;dr; You need Multithreading and a Multicore computer for CPU bound problems. Most async problems are not CPU bound. Multitasking is way enough. And you can totally multitask using threads, even on a single core machine.
Of course it can be done on a single-processor system, and in fact it's much easier that way. It works the same way as running multiple processes -- the kernel, via a timer interrupt or other similar mechanism, suspends one, saving its machine state, and replacing that by the previously-saved state of another -- the only difference being that two threads of the same process share the same virtual memory space, making the task-switch much more efficient.
Multi-threading on multi-processor systems is actually much more difficult, since you have issues of simultaneous access to memory from multiple cpus/cores, and all the nasty memory synchronization issues that arise out of that.
I recenetly read it somewhere that I can do multithreading on single processor system as well. Is it correct? and if yes then what is the difference between single processor and multiple processor systems?
Yes you can do multithreading on a single processor system.
In multi-processor system , multiple threads execute , simultaneously on different cores. Eg- If there are two threads and two cores , then each thread would run on individual core.
In a single-processor system, multiple threads execute , one after the other or wait until one thread finishes or is preempted by the OS , depending on the thread priority and the OS policy.But the running threads , gives an illusion that they run simultaneous , relative to the required application response time of the User space application.
Time Comparison(Example):
if two threads take 10us each to execute, then on a 2 processor system , the net time take is 10us
if two threads take 10us each to execute, then on a 1 processor system , the net time take is 20us
You can have more than four active threads on a quad core system. There is scheduling, unless you can guarantee that processes won't try to create more threads than there are processors.
Yes, you can have multiple threads on a single-core computer.
The difference between single processor and multi-processor systems is that a multi-processor system can indeed do more than one thing at a time. It can do N things at a time, where N is the number of processor cores. A single-processor core can only do one thing at a time. As WhozCraig said in his comment, it's the difference between actual and perceived concurrency.