Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-01

Java vs. Freepascal

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

boci

Re!
OK, I understand (maybe).
So in java I create a server socket and add to a thread (the thread handle the client), and the main program wait the next socket.
In Pascal is possible?
The Java create dinamicaly thread (no controlling or array, only type: new class.threadname(thSocket);
That's all. I want to this is Pascal, but I don't want to use sscoket library, I want to create this unit for all platforms where avaible the thread and the socket unit. So It's possible?
Or I wait a later version?
Cow

Peter Vreman
Show quoted text 9 lines
Re! OK, I understand (maybe). So in java I create a server socket and add to a thread (the thread handle the client), and the main program wait the next socket. In Pascal is possible? The Java create dinamicaly thread (no controlling or array, only type: new class.threadname(thSocket); That's all. I want to this is Pascal, but I don't want to use sscoket library, I want to

create

this unit for all platforms where avaible the thread and the socket unit. So It's possible? Or I wait a later version?

When you want to use threads you should wait until threads are fully supported by FPC. Until then you can either wait or help implementing the thread support. Compiler support for threadvars is already available, but the implementation in the RTL is still missing. What still needs to be done in the current development compiler:

1. Add thread support to the RTL, a basic infrastructure has been created already. For linux the code could largely be taken from the current TTHread implementation

2. When the thread code is ready in the RTL the heapmanager can be made threadsafe (a quick hack would be to place a global heap lock) and some variables like exception-stacks and inoutres should be made a threadvar.

3. Adapt TThread class to use the new RTL functions

Mirek Novak
to boci: Re! OK, I understand (maybe). So in java I create a server socket and add to a thread…

Hi!

I am reading all of the message according to server-writing problem because I'm interested in too. IMHO you (bocci) have to decide for which platform you want to write your server. Because (IMHO) if you want to write linux server it's far more safer to use fork() instead of threads. The difference between "threaded" and "forked" server is that "forked" server makes independent instances of itself for every connection but threaded server makes thread within main program - the andvantage (for me as a programer who writes only 99% bug free code :o)) ) is: if you have a heavier bug in threaded program it can cause hang of the main program and no more connections will be accepted :o( on the other hand forked program crashes only forked child with a bug but father and other childern will continue its connections untouched. Communication between chidren and father can be done using IPC (see doc.).

This is my opinion, if someone else things its not good please tell me to take out of the darkness. :o))))

Mirek Novak

Roderick van Domburg
to Mirek Novak

Under Linux, the whole issue isn't that big of a deal really IMO. You can go for the select(), the poll() or alternatively the fork() or clone(). The only problem is that I try to keep my code portable to Win32 platforms, and I don't think that is possible unless I use threads.

As much as I would love to, I am not good enough of a programmer to support the development of the compiler to help the implementation of the multi-threading. :-\

Coming down to stability, how 'well' is the 1.1 development branch suited for use?

Peter Vreman
Coming down to stability, how 'well' is the 1.1 development branch suited for use?

It's rather stable, but sometimes it fails to build itself due new optimizations or something like that. You can also tryout new features like default parameters, interfaces and dynamic arrays. But for the last 2 you can expect some bugs. There are some files for thread support in the RTL, but not included by default yet.