Rob Spoor

Sheriff
+ Follow
since Oct 27, 2005
Merit badge: grant badges
Forum Moderator
Rob Spoor currently moderates these forums:
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rob Spoor

dimis lakis wrote:

Rob Spoor wrote:Mono was only a way to get .NET Framework 4.x projects to run on Linux, Since .NET 5.0, .NET is crossplatform and there's no longer a need for Mono.


So .net runs without problems at non windows platforms?


.NET 8.0 comes on several platforms, including with package managers. See https://dotnet.microsoft.com/en-us/download/dotnet/8.0 for more info. There are also official Docker images available, see https://hub.docker.com/r/microsoft/dotnet. I've been using the latter for a while now to automatically test some .NET SDKs I'm maintaining at work.

I thing Microsoft made an anti-Java  platform with C#    and .net


That was their plan, but it's never been able to kill Java, and I doubt it will in the future. C# and .NET are definitely bigger on the desktop, but on the server side Java is still bigger, and will probably remain so, especially with all the work Oracle has been spending on improving Java: new language features, but also better tools like jlink.
3 weeks ago
Mono was only a way to get .NET Framework 4.x projects to run on Linux, Since .NET 5.0, .NET is crossplatform and there's no longer a need for Mono.
3 weeks ago
You can use Ctrl+A to select all text instead of using the mouse. You can then also use delete, it will work the same as backspace.

I've tried your way (select all with the mouse, backspace, then start typing) but there's no highlight (both Java 11 and Java 23 on Windows). What Java and OS are you using?
3 weeks ago
Copyright infringement issues come to mind.

To expand a bit: AI can create code based on existing code. A lot of that code is licensed. Do you think that AI listens to those licenses? Some of its input may be GPL, but do you think any company is going to make their final product GPL? Or if AI uses my Apache 2.0 licensed code, do you think I'll ever get the required mention? The answer to both is "no".
1 month ago
I don't fully agree. While most people associate Eclipse with Java development, it comes in a variety of packages: https://www.eclipse.org/downloads/packages/. For instance, there's Eclipse for C/C++ and Eclipse for PHP. Technically you can use those for Java programming, but you'll probably miss a lot of tools etc. Eclipse possibly isn't even capable of compiling the code.
1 month ago
But the constructors of most collection implementations do support any type of collection, so you can easily create a list from a set and a set from a deque, etc.
1 month ago

Piet Souris wrote:@Rob,
any reason why you used orElseGet instead of orElse?


The argument to orElse isn't lazily evaluated, so you'd have the same problem you originally had - array[1] is parsed even if it isn't necessary, and it fails for any non-number.
1 month ago
It can be made more elegant by using Optional:
1 month ago
Don't you mean Integer.parseInt(array[2]) instead of Integer.parseInt(array[1])?
1 month ago

Mike Simmons wrote:...


With a little reordering you can combine the Connection and CallableStatement in one try-with-resources block:
d.keys() does not return a list but a so-called dictionary view object. You can ask for its length, iterate over it, check if it contains elements, but not ask it for elements using an index.

Other than using list(d.keys()) to turn it into a list, you can use None as initial value. That will also work with empty dictionaries:
1 month ago

Tim Bant wrote:I had assumed that a .submit() or .execute() call was actually creating a thread, but now thanks to you both, I understand that its the service that creates the thread(s), then tasks are created via submit()/execute() and assigned/split out to the threads.


Some services may still create a thread for each task. For instance, Executors.newVirtualThreadPerTaskExecutor() returns a service that creates a new virtual thread for every task. But it's indeed the service that decides when to create or reuse threads.

Tim Bant wrote:One final comment...if I have:



it outputs 3 times.

Is this because its instantiating a new object everytime, thus creating a brand new thread pool each time?


Not a new thread pool - there is still the single es service. But every object has its own independent lock, and that's why each object's lock can be acquired regardless of the other objects' locks.
The reason why you see "Hellooooo" twice is because of the reentrant part.

Your executor service has two threads. You give it three tasks. That means that two tasks will need to be run in the same thread. If lock() is called in the same thread that already holds the lock it will acquire the lock, even if a different stuff instance is doing the work. Decrease the thread count to 1 and you'll see "Hellooooo" three times - because all locking is done on the same thread. Increase the thread count to 3 and each task will get its own thread, and you'll see only one "Hellooooo" like you expected.