• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 18:44
CET 00:44
KST 08:44
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win0Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down23ISSL (IntoTheTV x SOOP SC2 League): Premier7Weekly Cups (October 12-18): 5.0.17 era begins1
StarCraft 2
General
[D] Hacker peak in sc2 ? No more SC2 streamers on team liquid? Liquibets sc2 season 30 Evil Geniuses - shutting down Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win
Tourneys
SC4ALL: II Venue Change Announcement! Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays ISSL (IntoTheTV x SOOP SC2 League): Premier Stellar Fest TWO the Moon (Dec 16-20)
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps Starcraft 2 Advance [D] the control group Simple Questions/Answers
External Content
Mutation # 550 Graveyard Shift The PondCast: SC2 News & Results Mutation # 549 Endless Sparkles Mutation # 548 Shining Bright
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Rollback Netcode in Brood War SC4ALL: II Venue Change Announcement! Ziemie's Starcraft 1 Prequel Campaign 🇺🇦 Ukrainian StarCraft:BroodWar community reborn
Tourneys
[$1250] International ShieldBattery League [Megathread] Daily Proleagues Small VOD Thread 2.0 KCM Race Survival 2026 Season 4
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Deus Ex 3!? Mobile Legends: Bang Bang Armies of Exigo - YesYes?
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Dating: How's your luck? Trading/Investing Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread
Fan Clubs
Fan Club Resource Thread Reynor Fan Club The Flash Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8693 users

The Big Programming Thread - Page 548

Forum Index > General Forum
Post a Reply
Prev 1 546 547 548 549 550 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
Last Edited: 2014-11-17 22:27:28
November 17 2014 22:24 GMT
#10941
On November 18 2014 00:09 BByte wrote:
Show nested quote +
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


I'm also using Symfony (and now Kohana) and would also suggest Laravel. CodeIgniter is nice but it's rather dated and hasn't been developed for years so it might not adhere to the more modern approach and evolution of PHP itself. If you're new to the MVC pattern (that's what you call it) I'd suggest trying it out first in mini (formerly known simply as php-mvc) which is a micro-framework that let's you get the gist of it in 30 minutes or so. It's pretty bare bones but that's good, you'll learn how things work and it'll be much easier for you to jump to full-stack frameworks like Laravel or Symphony which offer a much higher level of abstraction. Because they offer all those abstraction layers you might find yourself doing stuff without actually knowing or fully understanding what's going on. I don't know about mini but php-mvc also had an "advanced" fork where you got SASS support and Twig templating engine.

I used to really hate Symfony, but after trying out some other frameworks I'm actually missing it in my new job (except for Sonata and CMF parts of it, I still despise them).
Time is precious. Waste it wisely.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
November 17 2014 23:38 GMT
#10942
I can't get JSTL into my jsp. I am using this include statement which seems to work for everyone else on the internet.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

I am using maven and have the javaee-web-api dependency in my project and on my build path. I can see the JSTL packages inside the jar but my include statement just won't find them and I do not know why. It does work if I get the JSTL dependency specifically but that just makes wonder why they bundled the entire web api into one package if I can't actually use the stuff inside of it. I am sure I am missing something obvious ><
goody153
Profile Blog Joined April 2013
44313 Posts
November 18 2014 01:16 GMT
#10943
On November 18 2014 07:24 Manit0u wrote:
Show nested quote +
On November 18 2014 00:09 BByte wrote:
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


I'm also using Symfony (and now Kohana) and would also suggest Laravel. CodeIgniter is nice but it's rather dated and hasn't been developed for years so it might not adhere to the more modern approach and evolution of PHP itself. If you're new to the MVC pattern (that's what you call it) I'd suggest trying it out first in mini (formerly known simply as php-mvc) which is a micro-framework that let's you get the gist of it in 30 minutes or so. It's pretty bare bones but that's good, you'll learn how things work and it'll be much easier for you to jump to full-stack frameworks like Laravel or Symphony which offer a much higher level of abstraction. Because they offer all those abstraction layers you might find yourself doing stuff without actually knowing or fully understanding what's going on. I don't know about mini but php-mvc also had an "advanced" fork where you got SASS support and Twig templating engine.

I used to really hate Symfony, but after trying out some other frameworks I'm actually missing it in my new job (except for Sonata and CMF parts of it, I still despise them).

Ok i'll try this php-mini first. Thanks .

On November 18 2014 00:09 BByte wrote:
Show nested quote +
On November 17 2014 21:25 goody153 wrote:
I was specifically tasked to convert 2 websites that was hardcoded into MVC coding style(or architecture or whatever the term i should use) so i did some googling and i ended up finding 3 PHP framework that apparently commonly used and i believe would help me on the task which are CakePHP, Laravel and CodeIgniter.

I won't ask which one is the best since they all probably have their own pros and cons. So my question would be which PHP framework between CakePHP, Laravel and CodeIgniter have you guys used or have been using ? or have you switched from one framework to another ? or which framework have you had a wonderful experience or have worked on you? which didn't ?


I haven't used any of the mentioned frameworks extensively, I use Symfony both at work and for some of my own projects. Based on what impressions I have of the three mentioned, I'd choose Laravel.

The best framework really depends on what you actually need to convert those sites. If they are rather simple, you may want to consider using a micro-framework. Even something simple will force you to use a proper MVC model and micro-frameworks can be a lot easier to learn. You certainly don't have to use or learn to use every component even if you pick a heavier option though.

When converting an existing site I'd especially consider support for different types of template and configuration files. If the sites are currently hardcoded, it's likely the view / template code is written in raw HTML + PHP. You may want to keep it that way and just separate the business logic. But if you also need to create some new templates a proper template engine can be useful. Mixing different types of templates may not be the cleanest solution, but in can mean a lot less work. Same goes for config files: Maybe you want to keep some of the old PHP or XML files, but want to use YAML for the new files. If the framework can seamlessly support different types of configuration, it's a little easier.


What i'm trying to convert is raw HTML + PHP coded and i would like to use majority of the codes from it since i don't want to recreate most of the functions.



Alright people has also been saying Symphony or Laravel so i'll try both and get the feel which i would like to use. And i won't be using codeigniter since people said that easier but there is no support behind it anymore.

Thank guys.
this is a quote
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
November 20 2014 02:12 GMT
#10944
Why are so many developers using MacBooks? Are they that good or is it just a trendy thing to do? I'm asking because I need a new laptop for work and am seriously considering giving it a shot even though I despise Apple products...
Time is precious. Waste it wisely.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2014-11-20 03:23:59
November 20 2014 02:28 GMT
#10945
My guess is that MacBooks are premium devices (good keyboard and touchpad, good screen, robust, good battery life etc..) and Mac OS X is POSIX compliant, which makes macbooks very usable in a Unix development setting. There are also a few productivity goodies on macbooks, like fancy multitouch touchpad gestures and such.

But they could probably do the same shit they do with a computer half as cheap. Apple's marketing and brand loyalty is just that good.
phar
Profile Joined August 2011
United States1080 Posts
November 20 2014 02:29 GMT
#10946
Solid product, and usually someone else (your company) is paying.
Who after all is today speaking about the destruction of the Armenians?
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 20 2014 02:30 GMT
#10947
On November 18 2014 08:38 Azerbaijan wrote:
I can't get JSTL into my jsp. I am using this include statement which seems to work for everyone else on the internet.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

I am using maven and have the javaee-web-api dependency in my project and on my build path. I can see the JSTL packages inside the jar but my include statement just won't find them and I do not know why. It does work if I get the JSTL dependency specifically but that just makes wonder why they bundled the entire web api into one package if I can't actually use the stuff inside of it. I am sure I am missing something obvious ><


What container are you deploying to? How are you declaring your dependency for the javaee-web-api and what version?
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
November 20 2014 02:41 GMT
#10948
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.
Time is precious. Waste it wisely.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
November 20 2014 03:02 GMT
#10949
On November 20 2014 11:41 Manit0u wrote:
Show nested quote +
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.

MSI and ASUS make good laptops for a good price, if you want something with a bit more power (especially graphics-wise).

There's a lot more options when it comes to extremely barebones machines.
Average means I'm better than half of you.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
November 20 2014 07:40 GMT
#10950
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)


RIP GOMTV. RIP PROLEAGUE.
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
November 20 2014 08:40 GMT
#10951
On November 20 2014 16:40 teamamerica wrote:
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)




Ad. 2:

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

Source: http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space
Time is precious. Waste it wisely.
Manit0u
Profile Blog Joined August 2004
Poland17871 Posts
November 20 2014 14:56 GMT
#10952


Good times...
Time is precious. Waste it wisely.
raNazUra
Profile Joined December 2012
United States10 Posts
November 20 2014 21:18 GMT
#10953
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 01:07 GMT
#10954
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 02:34 GMT
#10955
On November 20 2014 16:40 teamamerica wrote:
Hey guys, I was wondering how the elasticsearch option "mlockall" to prevent JVM from using heap memory is actually implemented.

Also was wondering - at work they have some elasticsearch nodes (I don't work on them, I just do monitoring T_T) but I was looking into the boxes for some issue and was seeing few things I had question on

1) JVM were configured with mlockall but were still using swap (these are running on physical servers). Shouldn't they not be?
2) Servers have 100gb RAM and were at maybe 80gb usage, was seeing there was still some swap usage. Why would anything use swap space before ram gets filled (vm.swapiness set to 60 if thats reason)




5 minutes of googling (so if its wrong, sorry..) shows that mlockall with the jvm is used through the lucid works java agent.

Lucid Works Java Agent

Are you guys following their recommended settings?
raNazUra
Profile Joined December 2012
United States10 Posts
November 21 2014 03:15 GMT
#10956
On November 21 2014 10:07 berated- wrote:
Show nested quote +
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 03:27 GMT
#10957
On November 21 2014 12:15 raNazUra wrote:
Show nested quote +
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.
phar
Profile Joined August 2011
United States1080 Posts
November 21 2014 05:34 GMT
#10958
On November 20 2014 11:41 Manit0u wrote:
Show nested quote +
On November 20 2014 11:29 phar wrote:
Solid product, and usually someone else (your company) is paying.


The thing is, I have to buy it myself for my personal use. Just found out I can get just as good MSI laptop for half the price.

Yea I personally wouldn't spend the markup out of my own pocket. But then again, if I had no company phone and had to get my own phone, I'd be eyeing the $100 moto e.
Who after all is today speaking about the destruction of the Armenians?
raNazUra
Profile Joined December 2012
United States10 Posts
November 21 2014 06:03 GMT
#10959
On November 21 2014 12:27 berated- wrote:
Show nested quote +
On November 21 2014 12:15 raNazUra wrote:
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.


Ok, so I'll just give a high-level picture of what I was hoping for. There's probably a proper paradigm for doing what I want to do, so that would also be welcome advice. Here's what I want:

main:
Run some code
Create a couple buttons, one of which is "Done tinkering"
Run some more code based on previous button presses (including possible branches)
More buttons, including "Done" button,
etc.

So my goal was to spawn a new thread for all the buttons, which will terminate when I'm done messing with them, at which point the main thread continues on. Originally I was being even terribler, and passing the future code to be executed around inside Buttons, which would get sent an event when the "Done" button was pressed.

Basically, when "Done" is pressed, I would greatly prefer to back out one level to whatever set it up, rather than pass the future code into the "Done" creation to be executed on the press.
Speak the truth, even if your voice shakes
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 21 2014 10:49 GMT
#10960
On November 21 2014 15:03 raNazUra wrote:
Show nested quote +
On November 21 2014 12:27 berated- wrote:
On November 21 2014 12:15 raNazUra wrote:
On November 21 2014 10:07 berated- wrote:
On November 21 2014 06:18 raNazUra wrote:
I have a code question. The long and the short of it is that I don't fully understand threads in Java, or perhaps simply their interaction with applets. Here's a simplified version of the problem I'm having:

+ Show Spoiler +
import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestApplet extends Applet {
public Button spawnThread;

private class ButtonPresser implements Runnable {

public Button endThread;
public TestApplet parent;
public Object notifier = new Object();

public ButtonPresser(TestApplet parent){
this.parent = parent;
}

@Override
public void run() {
synchronized(notifier){
endThread = new Button("End Thread");
endThread.setBounds(0,100,100,20);
endThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
synchronized(notifier) {
notifier.notify();
}
}
});
parent.add(endThread);

try {
notifier.wait();
System.out.println("Thread is done!");
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}

public void init() {
final TestApplet thisApp = this;
spawnThread = new Button("Spawn Thread");
spawnThread.setBounds(0,0,100,20);
spawnThread.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Thread t = new Thread(new ButtonPresser(thisApp));
t.run();
try {
t.join();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
add(spawnThread);
}
}


What I am attempting to do is spawn a thread that adds a button to an applet that will kill said thread. In order to do this, I am creating a button whose listener tells it to notify the object on which the thread's run method is currently waiting, thereby allowing the run() to complete and the thread to terminate. However, when I run this and click on the Spawn Thread button, the End Thread button is added, and then the applet completely locks up (accepts no clicks and can't be closed, have to kill the process). Can anyone explain to me why this is? I'm sure I'm doing something fundamentally stupid but am not sure what it is.

Also, I know no one uses applets anymore, that's what I see on every Stack Overflow question I read, but my guess is that this problem is not inherent to applets, but rather to my understanding. Also it seems I should be trying to use the java.util.concurrent library, but I'd like to know why this doesn't work before moving there.


Thread.join

When you call thread.join() from the main thread, it is now going to wait on the other thread to finish before it moves on.

You've created a deadlock. Thread a creates thread b. Thread b must be stopped by an action on thread a. However, thread a is currently waiting for thread b to finish before it can respond. Everyone loses.

Also, you shouldn't be calling thread.run(). You should call thread.start().

Starting a thread


Yes, the join() functionality is what I wanted, but I think I know where the problem is now. I had been forgetting to think about which thread deals with the actual ClickEvent, which presumably would be the main thread for applets. So then the main thread is waiting on the created thread to finish and can't jump out to execute ActionListener code for button presses? Time to go test this.


Why do you want join? You shouldn't care on the thread that creates the second thread what the second thread is doing? You just want it running, yes? Join explicitly takes away the whole value that you created by offloading to another thread by rejoining them together.


Ok, so I'll just give a high-level picture of what I was hoping for. There's probably a proper paradigm for doing what I want to do, so that would also be welcome advice. Here's what I want:

main:
Run some code
Create a couple buttons, one of which is "Done tinkering"
Run some more code based on previous button presses (including possible branches)
More buttons, including "Done" button,
etc.

So my goal was to spawn a new thread for all the buttons, which will terminate when I'm done messing with them, at which point the main thread continues on. Originally I was being even terribler, and passing the future code to be executed around inside Buttons, which would get sent an event when the "Done" button was pressed.

Basically, when "Done" is pressed, I would greatly prefer to back out one level to whatever set it up, rather than pass the future code into the "Done" creation to be executed on the press.


Thanks for the explanation and high level view, it makes things easier than just looking at a block of code. I'm by no means an applet expert, but, I'm going to try to restate what I believe you are trying to accomplish and the describe the approach I would take.

You want to create an applet with action buttons on it, we'll call them A, B, and C for short. When you click any of the buttons, you will add a Stop (A|B|C) button, as well as start the Action (A|B|C). Clicking the stop button will terminate the action.

If this is the case, I would have some sort of listener on buttons A, B, C like you do now. However, from looking at your code, I would change where the logic runs. For me, it makes most sense for the original button listener to
- create the thread
- create the stop button
- create the stop button listener with a reference to the created thread
- start the thread
- add the button to the screen

Since the newly created button listener has reference to the newly created thread, the only thing you'll have to do click is to stop the thread. No reason for joins anywhere. The reason I would do it like this is from a separation of concerns part. The thread should be responsible for doing whatever background logic you want to be happening is. The main applet and button listeners are responsible for the coordination of the creation of threads and buttons.
Prev 1 546 547 548 549 550 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 11h 16m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nathanias 141
StarCraft: Brood War
Britney 7280
Shuttle 372
Dota 2
PGG 188
League of Legends
Doublelift4651
JimRising 713
Counter-Strike
jkaem79
Other Games
gofns9158
summit1g8675
Grubby2321
shahzam448
PiGStarcraft355
C9.Mang0262
syndereN177
XaKoH 117
Fuzer 84
NeuroSwarm46
ZombieGrub44
ViBE42
KnowMe26
PPMD25
Railgan22
Maynarde8
JuggernautJason4
Organizations
Other Games
BasetradeTV174
Counter-Strike
PGL85
[ Show 18 non-featured ]
StarCraft 2
• Hupsaiya 54
• RyuSc2 15
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Laughngamez YouTube
• Migwel
StarCraft: Brood War
• HerbMon 38
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV661
League of Legends
• Nemesis3589
• Jankos3563
• Scarra939
Other Games
• imaqtpie660
• Shiphtur189
Upcoming Events
IntoTheTV X SOOP
11h 16m
Reynor vs Solar
ByuN vs SHIN
Clem vs MaxPax
herO vs Rogue
IPSL
17h 16m
WorsT vs nOmaD
Dewalt vs andersOn
AI Arena Tournament
19h 16m
IntoTheTV X SOOP
1d 11h
IPSL
1d 17h
Azhi_Dahaki vs ggnore13
Double vs WIZARD
Replay Cast
1d 23h
Replay Cast
2 days
Sparkling Tuna Cup
3 days
WardiTV Invitational
3 days
YoungYakov vs Lambo
SHIN vs TBD
Percival vs Shameless
Solar vs TBD
PiGosaur Cup
4 days
[ Show More ]
The PondCast
5 days
KCM Race Survival
5 days
WardiTV Invitational
5 days
Liquipedia Results

Completed

Proleague 2026-11-05
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
Calamity Cup Div. A Season 8
IEM Beijing 2026
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026

Upcoming

Sector 951
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Underdog Cup 2026 Div 2-3
PGL Bucharest 2027
BLAST Bounty Winter 2027
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.