Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Slick + Multi-threading...  (Read 1510 times)
0 Members and 1 Guest are viewing this topic.
Offline Pickleninja

JGO Coder


Medals: 10
Projects: 1


I'm tired of working for someone else.


« Posted 2012-12-13 13:24:13 »

So I was having a discussion with the other programmer on my game and he stated that Slick is mono-threaded. I said "yeah, which means that we need to implement multi-threading ourselves".

He thinks it's a bad idea.

I don't see any other way to do a multi-player game without it being multi-threaded... for the simple fact that you can't halt the game for networking issues, and thus should handle all networking in a seperate thread. Same thing with the user interface...


What are your guys thoughts?  Smiley



-Pickle

Offline deathpat
« Reply #1 - Posted 2012-12-13 13:58:54 »

hello,

for sure you can't listen to sockets in the main thread. I invite you to have a look at the excellent Kryonet library done by Nate.

It creates a thread for listening to the incoming messages, the callback is executed also in this thread but you can just add incoming messages to a ConcurrentLinkedQueue and read this queue from the main thread at each loop iteration  ( that's what I'm doing for my game ).

Kryonet handles automatically serialization of messages using Kryo, and is really easy to use/setup Smiley

work in progress : D A E D A L U S
Offline sproingie

JGO Kernel


Medals: 202



« Reply #2 - Posted 2012-12-13 16:46:55 »

Most graphics libraries are single-threaded, no getting around that.  But your colleague's also right, doing your own concurrency from scratch using just threads is usually a bad idea.  Try instead something higher level like the stuff in java.util.concurrent or an actor system like Kilim or Jumi or one of the ones mentioned in this paper (it starts off with scala examples but don't worry, the libraries it compares are mostly java).  

If it's networking, consider using netty instead of thread-based concurrency.  And so on.  Moral of the story is: concurrency is tricky business, so use a library.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Pickleninja

JGO Coder


Medals: 10
Projects: 1


I'm tired of working for someone else.


« Reply #3 - Posted 2012-12-13 19:21:06 »

Most graphics libraries are single-threaded, no getting around that.  But your colleague's also right, doing your own concurrency from scratch using just threads is usually a bad idea.  Try instead something higher level like the stuff in java.util.concurrent or an actor system like Kilim or Jumi or one of the ones mentioned in this paper (it starts off with scala examples but don't worry, the libraries it compares are mostly java).  

If it's networking, consider using netty instead of thread-based concurrency.  And so on.  Moral of the story is: concurrency is tricky business, so use a library.


Thanks for your help guys, I will definitly try to implement any threads I'll use via library.

-Pickle Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (33 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (65 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!